Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix the amplpy error on search path?

Tags:

python

amplpy

I have recently installed Amplpy for python 3.6.5 (win 32 bit), but I am facing the following issue:

  • Please make sure that the AMPL folder is in the system search path, or specify the path via:
    AMPL(Environment('full path to the AMPL installation directory'))

RuntimeError                              Traceback (most recent call last)
<ipython-input-4-1768ae85d3ec> in <module>()
      1 from amplpy import AMPL
----> 2 ampl = AMPL()

D:\Poulad\Program\myprog\lib\site-packages\amplpy\ampl.py in __init__(self, environment, langext)
     83         if environment is None:
     84             try:
---> 85                 self._impl = amplpython.AMPL()
     86             except RuntimeError as e:
     87                 from sys import stderr

RuntimeError: AMPL could not be started: The system cannot find the file specified.

I have also added amplpy and amplpython paths to the search paths through sys.path.append() but the error is poping up again.

Would you please help me to fix the problem?

like image 789
Poulad Avatar asked Sep 17 '25 05:09

Poulad


1 Answers

You have to put the path of the ampl executable when you call ampl (line 2). So instead of:

ampl = AMPL()

you write:

ampl = AMPL(Environment('put/here/your/path/'))
like image 158
esperluette Avatar answered Sep 19 '25 18:09

esperluette