ExoPlex icon indicating copy to clipboard operation
ExoPlex copied to clipboard

Pexpect Error

Open joshuaekingsbury opened this issue 2 years ago • 5 comments

When running the file "example_by_mass.py" an error is thrown regarding pexpect.

` (base) C:\Users<username>\Downloads\ExoPlex_dist\ExoPlex_dist\Examples>python example_by_mass.py

Core composition: {'Fe': 100.0, 'Si': 0.0, 'O': 0.0, 'S': 0.0} Mantle composition: {'FeO': 0.0, 'SiO2': 52.55497015, 'MgO': 39.17101638, 'CaO': 3.81493827, 'Al2O3': 4.45907521} Mantle Fe# -0.0 Core Mass Percent = 32.816

Your closest grid filename is: 0.07CaMg_0.00FeMg_0.09AlMg_0.9SiMg_0.0NaMg_0.00Fe_U/LM_results.txt

Core composition: {'Fe': 100.0, 'Si': 0.0, 'O': 0.0, 'S': 0.0} Mantle composition: {'FeO': 0.0, 'SiO2': 52.55497015, 'MgO': 39.17101638, 'CaO': 3.81493827, 'Al2O3': 4.45907521} Mantle Fe# -0.0 Core Mass Percent = 32.816

Making upper mantle PerPlex phase file. This will be stored in: ../Calc_Solutions/0.07CaMg_0.00FeMg_0.09AlMg_0.9SiMg_0.0NaMg_0.00Fe_UM_results.txt Traceback (most recent call last): File "C:\Users\jkingsbury\Downloads\ExoPlex_dist\ExoPlex_dist\Examples\example_by_mass.py", line 95, in Planet = exo.run_planet_mass(Mass_planet,compositional_params,structure_params,layers,filename) File "C:\Users\jkingsbury\Downloads\ExoPlex_dist\ExoPlex_dist\ExoPlex\run_planet.py", line 49, in run_planet_mass Mantle_filename = run_perplex.run_perplex(*[Mantle_wt_per,compositional_params,[structure_params[0],structure_params[1],structure_params[2]],filename,True]) File "C:\Users\jkingsbury\Downloads\ExoPlex_dist\ExoPlex_dist\ExoPlex\run_perplex.py", line 118, in run_perplex p = pe.spawn(PerPlex_path+"/./build") AttributeError: module 'pexpect' has no attribute 'spawn' `

On two Windows computers using Anaconda (with python 3.9.7, pexpect version 4.8.0, and the latest ExoPlex version), the example file works on one machine and not on the other. The error is also thrown on another computer using pexpect 4.6.0 and upgrading pexpect to 4.8.0 didn't correct the issue.

In the pexpect documentation, it states pexpect.spawn doesn't work on Windows. https://pexpect.readthedocs.io/en/stable/install.html#requirements

Even more confusing, the newest version works on my Windows machine, but using an older version of ExoPlex in another directory but the same terminal fails with the error above. Switching directories back to the newer ExoPlex immediately after works on my machine. However both new and old versions throw the above error on other Windows machines. I haven't been able to figure out what the differentiating factor is here.

joshuaekingsbury avatar Apr 14 '22 04:04 joshuaekingsbury

I also have an instance of this issue on a Linux machine, I can provide more info if needed.

joshuaekingsbury avatar Apr 14 '22 04:04 joshuaekingsbury

I figured out pexpect in run_perplex.py also fails in the working setups, but the code returns before it gets to fail.

I haven't gotten far enough to understand why between two freshly unzipped directories of ExoPlex, one might return before point-of-failure and complete successfully while the other fails to return and hits the point of failure.

joshuaekingsbury avatar Apr 14 '22 11:04 joshuaekingsbury

Interesting! I don't have a windows machine so I was never able to test any of the code out on that platform. I'll add a note to the code description stating that.

Although I will say this should only affect things if you want to run PerPlex for a composition outside of the grids (or need a very specific one). If you set use_grids = True, then it should bypass pexpect altogether.

CaymanUnterborn avatar Apr 14 '22 18:04 CaymanUnterborn

Hi @joshuaekingsbury, was this ever solved? I'm debating making a windows version once I get access to a machine regularly.

CaymanUnterborn avatar Jul 13 '22 23:07 CaymanUnterborn

Hello @CaymanUnterborn, the problem eventually seemed to stem from the Solutions_Small files missing from the directory after downloading and extracting. I'm not sure if the files were missing from the code .zip download for some reason or were not properly extracted. Replacing the Solutions_Small directory/files solved the issue if I remember correctly. I no longer have the laptop I was using at the time and so unfortunately cannot check. Once the school year begins I'll try to check with the peers I was helping troubleshoot at the time.

While the pexpect error was thrown on Windows machines when the files were missing, the issue of missing files did not seem to be platform specific.

joshuaekingsbury avatar Aug 22 '22 02:08 joshuaekingsbury