SystemError: License not valid

Traceback (most recent call last):
  File "run.py", line 10, in <module>
    ampl = AMPL()
  File "C:\Users\Asus\.conda\envs\network_flow_env\lib\site-packages\amplpy\ampl.py", line 102, in __init__
    self._impl = amplpython.AMPL()
SystemError: License not valid.
Message:
Cannot open $AMPL_LICFILE = "C:\Program Files\AMPL\ampl_mswin64"
AMPL Development Version 20230912 (MSVC 19.35.32217.1, 64-bit)

Hi @Anthony_Nwachukwu,

Did you set the environment variable AMPL_LICFILE to C:\Program Files\AMPL\ampl_mswin64? The directory ampl_mswin64 seems to be a time-limited bundle, to use amplpy with it you can do that as follows:

from amplpy import AMPL, add_to_path
add_to_path(r"C:\Program Files\AMPL\ampl_mswin64")
ampl.eval("option version;")

Thank you so much for the quick response. It works well now. I suggest you include this in the documentation because I spent lots of time looking for this information. It would save others the stress in the future.

1 Like

This is in the documentation at: Initial Setup — AMPL API 2.1 (amplpy-0.12.1) documentation

Ok, my bad :slight_smile: Next time, I will be more diligent.

1 Like