ampl / amplpy

Python API for AMPL

Home Page:https://amplpy.ampl.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'Environment' is not defined

sepulchreant opened this issue · comments

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.

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'

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.

Could you please run the following three commands:

  • python -m pip install amplpy --upgrade --force-reinstall
  • python -m pip show amplpy
  • python -c "import amplpy; print(amplpy.__version__, amplpy.__file__)"

and send us the output for each of them?

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

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/...

Thank you ! It works right now