FAQ
How do I prevent the 'cores licensing error when I run import pykx?
>>> import pykx as kx
<frozen importlib._bootstrap>:228: PyKXWarning: Failed to initialize embedded q; falling back to unlicensed mode, which has limited functionality. Refer to https://code.kx.com/pykx/user-guide/advanced/modes.html for more information. Captured output from initialization attempt:
'2022.09.15T10:32:13.419 license error: cores
This error indicates that KDB-X Python tried to use more cores than your license allows. You can fix this by limiting the number of cores used by the python process.
- On Linux you can use
tasksetto limit the number of cores used by a process:
# Example to limit python to the 4 first cores on a 8 cores CPU
$ taskset -c 0-3 python
- You can also do this in python before importing KDB-X Python (Linux only):
>>> import os
>>> os.sched_setaffinity(0, [0, 1, 2, 3])
>>> import pykx as kx
>>> kx.q('til 10')
pykx.LongVector(pykx.q('0 1 2 3 4 5 6 7 8 9'))
- On Windows you can use the
startcommand with its/affinityargument (see:> help start):
> start /affinity f python
(above, 0xf = 00001111b, so the python process will only use the four cores for which the mask bits are equal to 1)
How does KDB-X Python determine the license that is used?
The following steps are run by pykx to find the license when you execute import pykx:
- Search for kx.lic, kc.lic and k4.lic license files in this order within the following locations:
- Current working directory
- Location defined by environment variable
QLICif set - Location defined by environment variable
QHOMEif set
- If a license is not found KDB-X Python will use the following environment variables (if they are set) to install and make use of a license:
KDB_LICENSE_B64containing a base64 encoded version of a kc.lic licenseKDB_K4LICENSE_B64containing a base64 encoded version of a k4.lic license
- If a license has not been located you will be guided to install a license following a prompt based license installation.