PyKXException - Valid KDB+/Q License

https://learninghub.kx.com/forums/topic/pykxexception-valid-kdb-q-license

Hello,

Currently using trial kdb version, it's working well.

``` KDB+ 4.1 2024.10.16 Copyright (C) 1993-2024 Kx Systems l64/ 4(24)core 7461MB rr local 127.0.1.1 EXPIRE 2025.12.14 @gmail.com KDB PLUS TRIAL #xxxx365

<p>Tried installing PyKX and it's dependencies.</p>
Linux local 6.8.0-50-generic #51~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 21 12:03:03 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Python 3.10.12 (main, Nov 6 2024, 20:22:13) [GCC 11.4.0] on linuxType “help”, “copyright”, “credits” or “license” for more information.

When I have tried for first time, that is, importing pykx, it worked.

import pykx as kx

kx.license.install(‘/home/rr/q/l64/kc.lic’)
PyKX license successfully installed!

<p>However after installing kdb+ license, started throwing the below error. How to fix this issue? appreciate your help! Thanks</p>
kx.q.til(5)

Traceback (most recent call last):File “/home/rr/.local/lib/python3.10/site-packages/pykx/init.py”, line 152, in /.getattrctx = self.getattribute(‘ctx’)AttributeError: ‘EmbeddedQ’ object has no attribute ‘ctx’

import pykx as kx

Traceback (most recent call last):File "<stdin>", line 1, in <module>File "/home/rr/.local/lib/python3.10/site-packages/pykx/init.py", line 32, in <module>from . import coreFile "pykx/core.pyx", line 394, in init pykx.corepykx.exceptions.PyKXException: Early garbage collection requires a valid q license.

```<br />

What version of PyKX are you using?

In a q session can you use the new license?

Does it have the needed flags for PyKX?

q)`insights.lib.embedq`insights.lib.pykx in `$" " vs .z.l 4 // Should return 11b


When you run import pykx as kx  did you paste the full output? PyKX does try to include what is specifically wrong with a license.


Thanks for your response, please see below.

q shell output

KDB+ 4.1 2024.10.16 Copyright (C) 1993-2024 Kx Systems
l64/ 4(24)core 7461MB rr rkr 127.0.1.1 EXPIRE 2026.01.04 @gmail.com KDB INSIGHTS #xxxx593
q)`insights.lib.embedq`insights.lib.pykx in `$" " vs .z.l 4 // Should return 11b
11b
q)\\

pykx import error snapshot

Python 3.10.12 (main, Nov  6 2024, 20:22:13) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pykx as kx
Traceback (most recent call last):
File "", line 1, in
File "/home/rr/.local/lib/python3.10/site-packages/pykx/__init__.py", line 32, in
from . import core
File "pykx/core.pyx", line 394, in init pykx.core
pykx.exceptions.PyKXException: Early garbage collection requires a valid q license.
>>> quit()

pip installation output

$ pip3.10 install pykx
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pykx in /home/rr/.local/lib/python3.10/site-packages (3.0.1)
Requirement already satisfied: dill>=0.2.0 in /home/rr/.local/lib/python3.10/site-packages (from pykx) (0.3.9)
Requirement already satisfied: pandas<=2.2.3,>=1.2 in /home/rr/.local/lib/python3.10/site-packages (from pykx) (2.2.3)
Requirement already satisfied: toml~=0.10.2 in /home/rr/.local/lib/python3.10/site-packages (from pykx) (0.10.2)
Requirement already satisfied: numpy<2.0,~=1.22 in /home/rr/.local/lib/python3.10/site-packages (from pykx) (1.26.4)
Requirement already satisfied: pytz>=2022.1 in /usr/lib/python3/dist-packages (from pykx) (2022.1)
Requirement already satisfied: requests>=2.25.0 in /home/rr/.local/lib/python3.10/site-packages (from pykx) (2.32.3)
Requirement already satisfied: tzdata>=2022.7 in /home/rr/.local/lib/python3.10/site-packages (from pandas<=2.2.3,>=1.2->pykx) (2024.2)
Requirement already satisfied: python-dateutil>=2.8.2 in /home/rr/.local/lib/python3.10/site-packages (from pandas<=2.2.3,>=1.2->pykx) (2.9.0.post0)
Requirement already satisfied: charset-normalizer<4,>=2 in /home/rr/.local/lib/python3.10/site-packages (from requests>=2.25.0->pykx) (3.4.1)
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/lib/python3/dist-packages (from requests>=2.25.0->pykx) (1.26.5)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3/dist-packages (from requests>=2.25.0->pykx) (2020.6.20)
Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3/dist-packages (from requests>=2.25.0->pykx) (3.3)
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.8.2->pandas<=2.2.3,>=1.2->pykx) (1.16.0)

Do you have warnings supressed?


The output of the failed import should be like:

PYKX_GC=True python test.py
:241: PyKXWarning: Failed to initialize PyKX successfully with the following error: Captured output from initialization attempt:
'2025.01.10T12:11:03.276 licence error: k4.lic
License location used:
Traceback (most recent call last):
File "/home/rocuinneagain/q/test.py", line 1, in
import pykx as kx
File "/home/rocuinneagain/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pykx/__init__.py", line 32, in
from . import core
File "pykx/core.pyx", line 394, in init pykx.core
pykx.exceptions.PyKXException: Early garbage collection requires a valid q license.

Your output is missing the first line.


Do you have the QLIC environment variable set?


You put your license in /home/rr/q/l64/

A more standard location would be one level higher at /home/rr/q/

Can you start python with PYKX_UNLICENSED=True python

Then run:

>>> import pykx as kx
>>> kx.util.debug_environment()

And share the output here? It will give more information on your environment.