ampl / amplpy

Python API for AMPL
https://amplpy.ampl.com
BSD 3-Clause "New" or "Revised" License
64 stars 19 forks source link

'Environment' is not defined #50

Closed sepulchreant closed 1 year ago

sepulchreant commented 1 year ago

Capture d’écran 2023-02-28 à 12 48 29

There is a problem when running amplpy. Environment is not defined in the ampl files. All imports are good in my script and python recognizes amplpy and Environment so I do not understand.

fdabrandao commented 1 year ago

Hi @sepulchreant, could you please check the amplpy version you have installed? That line in the error message is not how it is currently implemented. The latest release is 0.8.6. You can upgrade with "python -m pip install amplpy --upgrade".

>>> import amplpy
>>> amplpy.__version__
'0.8.6'
sepulchreant commented 1 year ago

Hi, I have the last version installed. And I entered your command in my terminal but all requirements are already satisfied. Do you have any other idea ? Thank you.

fdabrandao commented 1 year ago

Could you please run the following three commands:

and send us the output for each of them?

sepulchreant commented 1 year ago

Capture d’écran 2023-02-28 à 15 25 03 Capture d’écran 2023-02-28 à 15 25 25 Capture d’écran 2023-02-28 à 15 26 40

Here you have. Still not ok with the reinstalled amply

fdabrandao commented 1 year ago

Thank for you providing these outputs. We can see that amplpy 0.8.6 is installed in /opt/anaconda3/lib/pyton3.7/site-packages, but there is another amplpy installed in /usr/local/Cellar/python/3.7.7/... (this is the one that is causing the error)

If you run python -c "import sys; print(sys.path)" you may see /usr/local/Cellar/python/3.7.7/... showing first in sys.path which results in that version being loaded.

Could you please run outside the anaconda environment: python -m pip uninstall amplpy to see if that uninstalls the version that is currently at /usr/local/Cellar/python/3.7.7/...

sepulchreant commented 1 year ago

Thank you ! It works right now