KxSystems / pyq

PyQ — Python for kdb+
http://code.kx.com/q/interfaces
Apache License 2.0
191 stars 49 forks source link

symbol error while running "pyq -m notebook " #36

Closed alexzhang2010 closed 6 years ago

alexzhang2010 commented 6 years ago

I am installed pyq 4.1.2 succesfully on redhat 2.7. When I run pyq from the shell, everything works fine.

(env_py36) [a393831@lrtp9101 ~]$ pyq
Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 13 2017, 12:05:00) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyq
>>> print(pyq.__version__)
4.1.2
>>> 

But when I launched the notebook with "pyq -m notebook ", and tried to the above code from notebook. I received the following error (also see the attached screen shot) pyq-notebook-error


ImportError                               Traceback (most recent call last)
/apps/anaconda3/envs/env_py36/lib/python3.6/site-packages/pyq/__init__.py in <module>()
     21 try:
---> 22     from ._k import K as _K, error as kerr, Q_VERSION, Q_DATE, Q_OS
     23 except ImportError:

ImportError: /apps/anaconda3/envs/env_py36/lib/python3.6/site-packages/pyq/_k.cpython-36m-x86_64-linux-gnu.so: undefined symbol: sd1

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-1-7abfe09f4cdb> in <module>()
----> 1 import pyq
      2 print(tf.__version__)
      3 print(pyq.__version__)

/apps/anaconda3/envs/env_py36/lib/python3.6/site-packages/pyq/__init__.py in <module>()
     29         else:
     30             message += "Use pyq executable."
---> 31         raise ImportError(message)
     32     raise
     33 

ImportError: Importing pyq from stock python is not supported. Use pyq executable.
abalkin commented 6 years ago

In order to use pyq in a Jupyter notebook, you need to install pyq-kernel. See https://pypi.python.org/pypi/pyq-kernel.

pip install pyq-kernel
pyq -m pyq.kernel install
abalkin commented 6 years ago

Alternatively, if you don't need to interact with the kernel via kdb+ IPC, you can simply locate your main kernel.json file (e.g. using the jupyter kernelspec list command) end replace "python" with "pyq" in the "argv" list.

alexzhang2010 commented 6 years ago

unfortunately, installing pyq-kernel does not help. This issue seems have something to do with anaconda 5.0. I downgraded it to anaconda 4.4 (with python 3.6.3, pyq 4.1.2) and it started working.

abalkin commented 6 years ago

How do you get Anaconda 5.0? I am looking at our recent Travis build https://travis-ci.org/KxSystems/pyq/jobs/305481268 and we seem to pick up conda-4.3.30.

sashkab commented 6 years ago

@abalkin anaconda distribution is 5.0.1, but conda package is... different. Different versions of anaconda.

@alexzhang2010 when you were using anaconda 5 based virtualenv, after you installed the pyq-kernel, did you change kernel from Python 3.6 to PyQ 3 kernel? Error message you were getting means, that most likely Python 3.6 kernel was used.

To help you troubleshoot -- please provide outputs of:

jupyter kernelspec list

And attach the .ipynb file with the notebook which failed to work.

alexzhang2010 commented 6 years ago

https://www.anaconda.com/download/

The latest build is 5.0.1 released on 10/25

alexzhang2010 commented 6 years ago

When I was using anaconda 4.4, I don’t have to install pyq-kernel. I just used python 3.6 kernel and import pyq works fine.

After I upgraded to anaconda 5.0.1, I got the same symbol error both with PyQ 3 kernel and with Python 3 kernel.

sashkab commented 6 years ago

@alexzhang2010 error you're getting is expected and is not a problem. In order to use IPython Notebooks with PyQ, you need to install ipython-kernel as suggested above by @abalkin, and use PyQ kernel for your notebook. While there you will have access to %q single line magic and %%q multiline magic.

alexzhang2010 commented 6 years ago

With anaconda 5.0.1, I installed pyq-kernel and used the pyq3 kernel, I ran into the same error.

Why it works with anaconda 4.4 even without installing pyq-kernel?

From: Aleks Bunin [mailto:notifications@github.com] Sent: Monday, November 27, 2017 10:34 PM To: KxSystems/pyq Cc: Zhang, Ray; Mention Subject: Re: [KxSystems/pyq] symbol error while running "pyq -m notebook " (#36)

@alexzhang2010https://github.com/alexzhang2010 error you're getting is expected and is not a problem. In order to use IPython Notebooks with PyQ, you need to install ipython-kernelhttps://pypi.python.org/pypi/pyq-kernel as suggestedhttps://github.com/KxSystems/pyq/issues/36#issuecomment-347343938 above by @abalkinhttps://github.com/abalkin, and use PyQ kernel for your notebook. While there you will have access to %q single line magic and %%q multiline magic.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/KxSystems/pyq/issues/36#issuecomment-347403562, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADp9u_WT6LhyReSKpHGrw36ueoLZ5W_hks5s639FgaJpZM4QsWCI.