# SystemError: License not valid

**URL:** <https://discuss.ampl.com/t/systemerror-license-not-valid/823>\
**Category:** Support\
**Created:** [November 22, 2023, 4:11pm UTC](https://discuss.ampl.com/t/systemerror-license-not-valid/823 "2023-11-22T16:11:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anthony\_Nwachukwu](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/anthony_nwachukwu/32/491_2.png) [@Anthony\_Nwachukwu](https://discuss.ampl.com/u/Anthony_Nwachukwu)\
**Post date:** [November 22, 2023, 4:11pm UTC](https://discuss.ampl.com/t/systemerror-license-not-valid/823/1 "2023-11-22T16:11:29Z")

</div>

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![fdabrandao](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/fdabrandao/32/63_2.png) [@fdabrandao](https://discuss.ampl.com/u/fdabrandao)\
**Post date:** [November 22, 2023, 4:15pm UTC](https://discuss.ampl.com/t/systemerror-license-not-valid/823/2 "2023-11-22T16:15:01Z")

</div>

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:

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

```

---

<div class="post-metadata">

**Author:** ![Anthony\_Nwachukwu](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/anthony_nwachukwu/32/491_2.png) [@Anthony\_Nwachukwu](https://discuss.ampl.com/u/Anthony_Nwachukwu)\
**Post date:** [November 22, 2023, 4:21pm UTC](https://discuss.ampl.com/t/systemerror-license-not-valid/823/3 "2023-11-22T16:21:24Z")

</div>

> [@fdabrandao](#):
>
> ```auto
> 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.

---

<div class="post-metadata">

**Author:** ![fdabrandao](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/fdabrandao/32/63_2.png) [@fdabrandao](https://discuss.ampl.com/u/fdabrandao)\
**Post date:** [November 22, 2023, 4:22pm UTC](https://discuss.ampl.com/t/systemerror-license-not-valid/823/4 "2023-11-22T16:22:27Z")

</div>

This is in the documentation at: [Initial Setup — AMPL API 2.1 (amplpy-0.12.1) documentation](https://amplpy.ampl.com/en/latest/getting-started.html#development)

---

<div class="post-metadata">

**Author:** ![Anthony\_Nwachukwu](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/anthony_nwachukwu/32/491_2.png) [@Anthony\_Nwachukwu](https://discuss.ampl.com/u/Anthony_Nwachukwu)\
**Post date:** [November 22, 2023, 4:23pm UTC](https://discuss.ampl.com/t/systemerror-license-not-valid/823/5 "2023-11-22T16:23:50Z")

</div>

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