# LicenseException: A valid q license must be in a known location (e.g. \`$QLIC\`) to run q code via 'pykx.q'.

**URL:** <https://forum.kx.com/t/licenseexception-a-valid-q-license-must-be-in-a-known-location-e-g-qlic-to-run-q-code-via-pykx-q/12972>\
**Category:** Community Support\
**Tags:** pykx\
**Created:** [August 8, 2023, 7:20pm UTC](https://forum.kx.com/t/licenseexception-a-valid-q-license-must-be-in-a-known-location-e-g-qlic-to-run-q-code-via-pykx-q/12972 "2023-08-08T19:20:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amod1](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@Amod1](https://forum.kx.com/u/Amod1)\
**Post date:** [August 8, 2023, 7:20pm UTC](https://forum.kx.com/t/licenseexception-a-valid-q-license-must-be-in-a-known-location-e-g-qlic-to-run-q-code-via-pykx-q/12972/1 "2023-08-08T19:20:00Z")

</div>

I am trying to run q commands through a jupyter notebook. However, I am running into the exception, whenever I am using pykx.q.&nbsp;

```
LicenseException: A valid q license must be in a known location (e.g. `$QLIC`) to run q code via 'pykx.q'.

```

&nbsp;Even while importing, I am encountering the issue

```
<frozen importlib._bootstrap>:241: PyKXWarning: Failed to initialize PyKX fully licensed functionality. To access all functionality of PyKX please download an evaluation license from[https://kx.com/kdb-insights-personal-edition-license-download/]("https://kx.com/kdb-insights-personal-edition-license-download/")Full installation instructions can be found at[https://code.kx.com/pykx/getting-started/installing.html]("https://code.kx.com/pykx/getting-started/installing.html")Falling back to unlicensed mode, which has limited functionality. Refer to[https://code.kx.com/pykx/user-guide/advanced/modes.html]("https://code.kx.com/pykx/user-guide/advanced/modes.html")for more information on licensed vs unlicensed modalities. Captured output from initialization attempt: '2023.08.08T18:49:30.065 licence error: embedq

```

&nbsp;

I am able to use q through CLI normally. The license file is there. But somehow the exception pops up whenever I am trying to run q commands through pykx.q. I have made sure that QHOME and QLIC are pointing to the folder containing kc.lic file.&nbsp;

Any help or guidance to fix this issue will be great.

&nbsp;

---

<div class="post-metadata">

**Author:** ![powerpeanuts1](https://avatars.discourse-cdn.com/v4/letter/p/b4bc9f/32.png) [@powerpeanuts1](https://forum.kx.com/u/powerpeanuts1)\
**Post date:** [August 9, 2023, 6:34am UTC](https://forum.kx.com/t/licenseexception-a-valid-q-license-must-be-in-a-known-location-e-g-qlic-to-run-q-code-via-pykx-q/12972/2 "2023-08-09T06:34:00Z")

</div>

I have similar issue as well, already set QLIC pointing to license folder, but get license error: upd, not sure if same root cause as yours.

---

<div class="post-metadata">

**Author:** ![rocuinneagain1](https://avatars.discourse-cdn.com/v4/letter/r/fbc32d/32.png) [@rocuinneagain1](https://forum.kx.com/u/rocuinneagain1)\
**Post date:** [August 9, 2023, 1:07pm UTC](https://forum.kx.com/t/licenseexception-a-valid-q-license-must-be-in-a-known-location-e-g-qlic-to-run-q-code-via-pykx-q/12972/3 "2023-08-09T13:07:00Z")

</div>

You license will need the flags&nbsp;`insights.lib.embedq` and `insights.lib.pykx`to run `pykx.q`

You can check your license flags in q using:

&nbsp;

&nbsp;

&nbsp;

q).z.l 4 "insights.lib.embedq insights.lib.pykx insights.lib.sql insights.lib.qlog ins..

&nbsp;

&nbsp;

&nbsp;

&nbsp;

If you have an older trial license you simply need to request a new one at:

https://kx.com/kdb-personal-edition-download/

[[https://kx.com/kdb-insights-personal-edition-license-download/](https://kx.com/kdb-insights-personal-edition-license-download/)](“[https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fkx.com%2Fkdb-insights-personal-edition-license-download%2F&data=05|01|rocuinneagain%40kx.com|6f9711c69dae4cf1149108db98e86f6d|8b006032f7cd404e8f6f4719f041417b|0|0|638271896306917562|Unknown|TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D|3000|||&sdata=%2Ba%2FLEYbCQZkAEtP0LacT5Ol8EDUWCZr0eqG5plhEwds%3D&reserved=0](https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fkx.com%2Fkdb-insights-personal-edition-license-download%2F&data=05%7C01%7Crocuinneagain%40kx.com%7C6f9711c69dae4cf1149108db98e86f6d%7C8b006032f7cd404e8f6f4719f041417b%7C0%7C0%7C638271896306917562%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=%2Ba%2FLEYbCQZkAEtP0LacT5Ol8EDUWCZr0eqG5plhEwds%3D&reserved=0)” "“Original”)

&nbsp;

Then replace the old with new on your machine. New licenses come with all the flags enabled.

&nbsp;

If it is a commercial license then your designated contact can reach out to&nbsp;licadmin@kx.com&nbsp;to have a new license issued:

https://code.kx.com/q/learn/licensing/#commercial

&nbsp;

---

<div class="post-metadata">

**Author:** ![rocuinneagain1](https://avatars.discourse-cdn.com/v4/letter/r/fbc32d/32.png) [@rocuinneagain1](https://forum.kx.com/u/rocuinneagain1)\
**Post date:** [August 9, 2023, 1:11pm UTC](https://forum.kx.com/t/licenseexception-a-valid-q-license-must-be-in-a-known-location-e-g-qlic-to-run-q-code-via-pykx-q/12972/4 "2023-08-09T13:11:00Z")

</div>

As well as a licence expiry date each kdb+ licence also has a maintenance update date.

- licence expiry: You cannot use kdb+ after this date gives&nbsp;`exp`&nbsp;error
- maintenance update expiry: You cannot use versions of kdb+ newer than this date. Gives&nbsp;`upd`&nbsp;error

https://code.kx.com/q/basics/errors/#:~:text=format%20not%20recognized-,upd,-Function%20upd%20is

&nbsp;

.e.g if you have a maintenance expiry date of 2021.12.31 but a licence expiry of 2022.06.01 this means you can use kdb+ up to 2022.06.01 as long as the version of kdb+ was released before 2021.12.31

The dates of your licence are included in the email you got from&nbsp;licadmin@kx.com

&nbsp;

As of 1.6.0 PyKX is based on&nbsp;2023.04.17 version of q

https://code.kx.com/pykx/1.6/changelog.html#pykx-160

&nbsp;

To get a new license with a more open maintenance expiry date&nbsp;your designated contact can reach out to&nbsp;licadmin@kx.com&nbsp;to have a new license issued:

https://code.kx.com/q/learn/licensing/#commercial

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Amod1](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@Amod1](https://forum.kx.com/u/Amod1)\
**Post date:** [August 9, 2023, 1:23pm UTC](https://forum.kx.com/t/licenseexception-a-valid-q-license-must-be-in-a-known-location-e-g-qlic-to-run-q-code-via-pykx-q/12972/5 "2023-08-09T13:23:00Z")

</div>

&nbsp;I checked for the flags but I got an empty string for the command.&nbsp;

I also ran&nbsp;python -c “import pykx;pykx.util.debug\_environment()”, based on one of previous answer. There also I got an empty string where flags are expected.

However, I think the license is not an older version as I got it just a few days back.&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![rocuinneagain1](https://avatars.discourse-cdn.com/v4/letter/r/fbc32d/32.png) [@rocuinneagain1](https://forum.kx.com/u/rocuinneagain1)\
**Post date:** [August 9, 2023, 4:07pm UTC](https://forum.kx.com/t/licenseexception-a-valid-q-license-must-be-in-a-known-location-e-g-qlic-to-run-q-code-via-pykx-q/12972/6 "2023-08-09T16:07:00Z")

</div>

I’ve corrected my link.

You specifically need the **insights** free trial license to get the flags:

[[https://kx.com/kdb-insights-personal-edition-license-download/](https://kx.com/kdb-insights-personal-edition-license-download/)](“[https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fkx.com%2Fkdb-insights-personal-edition-license-download%2F&data=05|01|rocuinneagain%40kx.com|6f9711c69dae4cf1149108db98e86f6d|8b006032f7cd404e8f6f4719f041417b|0|0|638271896306917562|Unknown|TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D|3000|||&sdata=%2Ba%2FLEYbCQZkAEtP0LacT5Ol8EDUWCZr0eqG5plhEwds%3D&reserved=0](https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fkx.com%2Fkdb-insights-personal-edition-license-download%2F&data=05%7C01%7Crocuinneagain%40kx.com%7C6f9711c69dae4cf1149108db98e86f6d%7C8b006032f7cd404e8f6f4719f041417b%7C0%7C0%7C638271896306917562%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=%2Ba%2FLEYbCQZkAEtP0LacT5Ol8EDUWCZr0eqG5plhEwds%3D&reserved=0)” "“Original”)

---

<div class="post-metadata">

**Author:** ![Amod1](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@Amod1](https://forum.kx.com/u/Amod1)\
**Post date:** [August 9, 2023, 9:59pm UTC](https://forum.kx.com/t/licenseexception-a-valid-q-license-must-be-in-a-known-location-e-g-qlic-to-run-q-code-via-pykx-q/12972/7 "2023-08-09T21:59:00Z")

</div>

&nbsp;I updated the license from here. Now I can see the flags by running .z.l 4 in q.

However, I am running into a new problem when executing&nbsp;python -c “import pykx;pykx.util.debug\_environment()” as shown in the screenshot below. Same error message pops up if I am importing it in python.&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![rocuinneagain1](https://avatars.discourse-cdn.com/v4/letter/r/fbc32d/32.png) [@rocuinneagain1](https://forum.kx.com/u/rocuinneagain1)\
**Post date:** [August 10, 2023, 2:03pm UTC](https://forum.kx.com/t/licenseexception-a-valid-q-license-must-be-in-a-known-location-e-g-qlic-to-run-q-code-via-pykx-q/12972/8 "2023-08-10T14:03:00Z")

</div>

Does the import work in unlicensed mode?

set QARGS=“–unlicensed”

&nbsp;

---

<div class="post-metadata">

**Author:** ![Amod1](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@Amod1](https://forum.kx.com/u/Amod1)\
**Post date:** [August 11, 2023, 12:15pm UTC](https://forum.kx.com/t/licenseexception-a-valid-q-license-must-be-in-a-known-location-e-g-qlic-to-run-q-code-via-pykx-q/12972/9 "2023-08-11T12:15:00Z")

</div>

Yes. Following is the screenshot for the same.&nbsp;

Everything seems fine, but again it fails with no license exception when I run a simple q command.

I don’t know how relevant it is but I’m using a Windows machine with windows 11 OS.

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![rocuinneagain1](https://avatars.discourse-cdn.com/v4/letter/r/fbc32d/32.png) [@rocuinneagain1](https://forum.kx.com/u/rocuinneagain1)\
**Post date:** [August 11, 2023, 1:26pm UTC](https://forum.kx.com/t/licenseexception-a-valid-q-license-must-be-in-a-known-location-e-g-qlic-to-run-q-code-via-pykx-q/12972/10 "2023-08-11T13:26:00Z")

</div>

It’s expected that you cannot run `pykx.q('1+1')` when in unlicensed mode.

&nbsp;

Can you try again for licensed mode after making&nbsp;a copy of:  
`C:\Users\Amod Shanker\anaconda3\envs\python396\python.EXE`

The copy should be `python3.EXE`:  
`C:\Users\Amod Shanker\anaconda3\envs\python396\python3.EXE`

&nbsp;

- just to confirm:

1. How did you install PyKX?

2. What version have you installed?&nbsp;`pykx. __version__ `&nbsp;or view it in&nbsp;`conda list`

---

<div class="post-metadata">

**Author:** ![Amod1](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@Amod1](https://forum.kx.com/u/Amod1)\
**Post date:** [August 11, 2023, 2:53pm UTC](https://forum.kx.com/t/licenseexception-a-valid-q-license-must-be-in-a-known-location-e-g-qlic-to-run-q-code-via-pykx-q/12972/11 "2023-08-11T14:53:00Z")

</div>

I tried with python3.exe, but the behaviour remains same. I can import in unlicensed mode but it fails with licensed mode throwing .nyi error.

&nbsp;

I installed pykx using pip. I have tried it with different versions of python, i.e. 3.9.6 and 3.8 in different conda environments. They both are behaving similarly.&nbsp;&nbsp;

They pykx version is 1.6.1 in my system.

&nbsp;
