1

This is the error message I am getting:

Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyq import q
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/pyq/__init__.py", line 21, in <module>  from . import _k
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/pyq/_k.cpython-36m-darwin.so, 2): Symbol not found: _b9  
Referenced from: 
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/pyq/_k.cpython-36m-darwin.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/pyq/_k.cpython-36m-darwin.so

My python version is 3.6 and pyq version is 4.0.1.

I installed pyq via pip and Python via regular OS install.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Alim Hasanov
  • 197
  • 1
  • 3
  • 16

2 Answers2

1

I think I got a solution: will be able to run [import pyq] when you run your python script with pyq binary. Exactly as you run a regular python script python xxx.py, you need instead to run it as pyq xxx.py

Alim Hasanov
  • 197
  • 1
  • 3
  • 16
1

PyQ is a python interpreter embedded in kdb+ and the pyq module cannot be imported in a stand-alone python. There are three ways to use pyq:

  1. At the q command prompt or in a q script start the line with a p) prefix and follow with a python statement. For example,

    p)from pyq import q
    p)print(q.til(5))
    

will print 0 1 2 3 4.

  1. You can place your python code in a file with the .p extension and use it as you would a q script: execute from command line

    $ q foo.p
    

or load using the \l command.

  1. Finally, the pyq executable gives a convenient way to run a standard Python REPL either interactively or to execute python programs. Internally, pyq executes q python.q, so your code still runs inside a kdb+ instance. Note that when you run pyq, Python REPL takes over and you cannot interact with your kdb+ instance using the standard kdb+ IPC mechanisms. If you require such communications, use one of the two options described above.
sashk
  • 3,946
  • 2
  • 33
  • 41
Alexander Belopolsky
  • 2,228
  • 10
  • 26