thermotools / thermopack

Thermopack is a thermodynamic model library for fluid properties and PVT calculations
Other
51 stars 13 forks source link

Seemingly Successful Installation Fails to Function #89

Closed tlorance closed 1 year ago

tlorance commented 1 year ago

I have recently installed thermopack via PyCharm; I would like to use it for LLE correlation and regression tasks. Despite the fact that PyCharm says thermopack is installed (and an independent attempt via the command line with pip3 agrees), when I try to run the first example in the documentation

from thermopack.saftvrmie import saftvrmie
eos = saftvrmie('C1,CO2')

I get the following errors:

Cannot find reference 'saftvrmie' in 'thermopack.py'
Unresolved reference 'saftvrmie'

I am sure that I have done something stupid in the installation, but I have no idea what. Could someone please grant a clue to the clueless? Thank you very much.

morteham commented 1 year ago

Hi!

The python interface in thermopack does not contain a file named thermopack.py. Can you check if you have local file that that is imported into your project? - Or if you have a thermopack.py somewhere on your system?

tlorance commented 1 year ago

I have a folder named thermopack (/usr/local/lib/python3.9/site-packages/thermopack) in the python interpreter installation I am attempting to use. Within that folder I have these files:

__pycache__     lee_kesler.py       multiparameter.py   plotutils.py        tcPR.py
cpa.py          libthermopack.dynlib    pcsaft.py       quantum_cubic.py    thermo.py
cubic.py        ljs_bh.py       pets.py         saftvrmie.py        utils.py

There does not seem to be a thermopack.py file; I am not sure why Python (PyCharm) is throwing this error. I did try, however, running:

eos = saftvrmie('C1,CO2')

instead; I obtained the error: ImportError: cannot import name 'saftvrmie' from partially initialized module 'thermopack' (most likely due to a circular import)

vegardjervell commented 1 year ago

Hi!

This seems a bit strange, but it might have something to do with the fact that there is no __init__.py in thethermopack directory. I also see that some other files appear to be missing. How have you installed thermopack?

I agree that this looks like some strange import behaviour. If you could give a full overview of your projects file tree, and add the entire script that causes the error, so that we can reproduce it, it will be easier to help you :)

tlorance commented 1 year ago

I installed thermopack through PyCharm (selected Interpreter Properties (for python3.9), went to Add Packages, etc.). PyCharm indicated that it had installed without problem. Could there be an old or defunct repository that PyCharm is pointed to by default? I have never had that happen before, but I have had trouble installing via PyCharm before... just never the problem that PyCharm said it worked and it doesn't. The script is in its own .py file within a file called Thermophysical_Equilibrium within a file call PyCharm_Projects (where all my Python programming projects live). As for the script itself, what was reproduced in my original post is the entire script: I was going to learn thermopack by running the examples in the documentation.

vegardjervell commented 1 year ago

I don't think there are any online defunct versions that pip could be installing by accident. What system are you on? If you're on a mac: Do you have an x86 (intel) chip or an arm (M1, M2 etc.) chip?

Until I'm able to reproduce the error the best advice I can give is probably that you try to uninstall and reinstall thermopack, it looks to me like something went wrong during the installation. If reinstalling doesn't work, you could try creating a new project, and selecting "new environment using virtualenv" to get a completely clean environment. If that doesn't work, you can upload a .zip of your project (with the venv directory) here so I can take a look :)

tlorance commented 1 year ago

My Mac is Intel (2.3 GHz 8-Core Intel Core i9). Reinstalling thermopack in the Python 3.9 interpreter did not help, but starting a new project and setting up a new virtual environment did seem to fix it. Does that mean the old virtual environment is corrupt?

vegardjervell commented 1 year ago

It seems like something has gone wrong when setting up the previous venv. I've never seen this behaviour from thermopack before, and if it works in a fresh venv, then I don't think it's an issue with the package.

Nice to hear you got it working though! I'll close this issue now, but feel free to ask, either here or on the discussions page if you have any questions :)