KxSystems / pyq

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

PyQ on Mac OS X error #34

Closed grokpronoia closed 6 years ago

grokpronoia commented 6 years ago

Using python 3.6. I have 2 versions of kdb installed on my system; the free 32-bit version and the 64-bit personal edition. I've successfully installed PyQ using pip3...

~ master*
❯ pip3 show pyq
Name: pyq
Version: 4.1.2
Summary: PyQ - Python for kdb+
Home-page: http://pyq.enlnt.com
Author: Enlightenment Research, LLC
Author-email: pyq@enlnt.com
License: PyQ General License
Location: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Requires:

When I enter the pyq command it throws the following error...

~ master*
❯ pyq
Welcome to kdb+ 32bit edition
For support please see http://groups.google.com/d/forum/personal-kdbplus
Tutorials can be found at http://code.kx.com/wiki/Tutorials
To exit, type \\
To remove this startup msg, edit q.q
'2017.11.25T15:31:18.701 dlopen(/Library/Frameworks/Python.framework/Versions/3.6/bin/python3:, 10): image not found
  [4]  /Users/marrowgari/q/p.k:3: (`p 2:(`p_init;1))python_dll

I've also tried using Virtualenv. Following the steps here...

~ master*
❯ pip3 show virtualenv
Name: virtualenv
Version: 15.1.0
Summary: Virtual Python Environment builder
Home-page: https://virtualenv.pypa.io/
Author: Jannis Leidel, Carl Meyer and Brian Rosner
Author-email: python-virtualenv@groups.google.com
License: MIT
Location: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Requires:

I've created the virtual environment and activated it...

~ master*
❯ virtualenv /Users/marrowgari/pykdb
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.6'
New python executable in /Users/marrowgari/pykdb/bin/python3.6
Also creating executable in /Users/marrowgari/pykdb/bin/python
Installing setuptools, pip, wheel...done.

~ master*
❯ source /Users/marrowgari/pykdb/bin/activate

~ master*
(pykdb) ❯

Since I have a license for my 64-bit personal edition I create a directory for it first...

~ master*
(pykdb) ❯ mkdir -p /Users/marrowgari/pykdb/q && unzip /Users/marrowgari/downloads/m64.zip -d /Users/marrowgari/pykdb/q
Archive:  /Users/marrowgari/downloads/m64.zip
  inflating: /Users/marrowgari/pykdb/q/m64/q
  inflating: /Users/marrowgari/pykdb/q/q.k

and check to make sure that it's been unzipped and installed properly...

~ master*
(pykdb) ❯ cd pykdb

~/pykdb master*
(pykdb) ❯ ls
bin                lib                q
include            pip-selfcheck.json

~/pykdb master*
(pykdb) ❯ cd q

~/pykdb/q master*
(pykdb) ❯ ls
m64 q.k

~/pykdb/q master*
(pykdb) ❯ cd m64

~/pykdb/q/m64 master*
(pykdb) ❯ ls
q

I copy my kdb license to the q folder previously created in the virtualenv... ❯ cp /Users/marrowgari/downloads/m64/kc.lic /Users/marrowgari/pykdb/q

and check to make sure it's been added...

~/pykdb/q master*
(pykdb) ❯ ls
kc.lic m64    q.k

I install PyQ in the virtualenv...

~/pykdb/q master*
(pykdb) ❯ pip3 install pyq
Collecting pyq
Installing collected packages: pyq
Successfully installed pyq-4.1.2

However, when I try to start an interactive session it throws the following error...

~/pykdb/q master*
(pykdb) ❯ pyq
Welcome to kdb+ 32bit edition
For support please see http://groups.google.com/d/forum/personal-kdbplus
Tutorials can be found at http://code.kx.com/wiki/Tutorials
To exit, type \\
To remove this startup msg, edit q.q
'2017.11.25T15:56:52.494 dlopen(/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6:, 10): image not found
  [4]  /Users/marrowgari/pykdb/q/p.k:3: (`p 2:(`p_init;1))python_dll

Any help on resolving this would be greatly appreciated. Thank you.

abalkin commented 6 years ago

Please follow Installing into a virtual environment instructions. The kdb+ zip archive should be extracted in ${VIRTUAL_ENV} ( the free edition) or ${VIRTUAL_ENV}/q after the virtual environment has been activated and before pip install.

You cannot have both 32-bit and 64-bit PyQ in the same environment, but if you use universal python binary, you can have your environments built from a common parent.

abalkin commented 6 years ago

@marrowgari - how did you get Python 3.6 on your system? We recommend using brew with a special tap. See Brewing Universal Python.

grokpronoia commented 6 years ago

@abalkin those are the instructions I was following. Everything seemed to work fine, as you can see from my code above, except starting the PyQ process. I've tried going back and reinstalling everything a few times, even re-downloading the 32-bit version and extracting in the virtual environment but it keeps throwing the same error...

~ master*
❯ pyq
Welcome to kdb+ 32bit edition
For support please see http://groups.google.com/d/forum/personal-kdbplus
Tutorials can be found at http://code.kx.com/wiki/Tutorials
To exit, type \\
To remove this startup msg, edit q.q
'2017.11.27T11:40:22.059 dlopen(/Library/Frameworks/Python.framework/Versions/3.6/bin/python3:, 10): image not found
  [4]  /Users/marrowgari/q/p.k:3: (`p 2:(`p_init;1))python_dll

In regards to your other question about Python, I installed it using brew install python3, which you can see below...

~ master*
❯ brew list
gcc     heroku      libmpc      openssl     rlwrap
gdbm        heroku-node mpfr        openssl@1.1 sqlite
git     icu4c       node        python3     wget
gmp     isl     numpy       readline    xz
abalkin commented 6 years ago

@marrowgari - brew install python3 will install 64bit python which is not compatible with the 32bit edition of kdb+.

I have just tried installing 64bit pyq on my macOS 10.12.6 machine and it all worked fine. How did you create your virtual environment?

sashkab commented 6 years ago
❯ virtualenv /Users/marrowgari/pykdb
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.6'

When you created virtual environment you did not use brewed python. virtualenv used python found in your path, which seems not one from the homebrew. In order to supply correct Python to the virtualenv, use following command:

virtualenv -p /usr/local/opt/python36/bin/python3.6 /Users/marrowgari/pyq32

Replace /usr/local/opt/python36/bin/python3.6 with the path to your brewed python.

If that doesn't work, please provide output of

brew info python3 python36
grokpronoia commented 6 years ago

@sashkab not using the correct version of python was the problem. Even though I had a brewed version of python on my machine, I had also downloaded the python3.6 framework from python.org. To fix the problem I had to completely remove python off of my system then re-install using brew with a special tap, Brewing Universal Python, as @abalkin mentioned above. Once the old versions of python were removed and the brewed version was the only one remaining on my system the rest of the installation went smoothly. Thank you for the help!

sashkab commented 6 years ago

@marrowgari Something else was wrong with your setup, as I just performed test installation on macOS with Python downloaded from the python.org. Just in case, this was fresh installation of macOS 10.13.1, with no Hombrew installed.

$ python3 -m pip install virtualenv 
Collecting virtualenv
  Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB)
    100% |████████████████████████████████| 1.8MB 609kB/s 
Installing collected packages: virtualenv
Successfully installed virtualenv-15.1.0
$ python3 -m virtualenv pyq
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.6'
New python executable in /Users/b/pyq/bin/python3
Also creating executable in /Users/b/pyq/bin/python
Installing setuptools, pip, wheel...done.
$ source pyq/bin/activate
(pyq) $ mv ~/Downloads/q $VIRTUAL_ENV/
(pyq) $ pip install pyq
Collecting pyq
  Downloading pyq-4.1.2.tar.gz (94kB)
    100% |████████████████████████████████| 102kB 3.0MB/s 
Building wheels for collected packages: pyq
  Running setup.py bdist_wheel for pyq ... done
  Stored in directory: /Users/b/Library/Caches/pip/wheels/ca/30/e1/f0cf8237ad1eb6691c5adbe753141249e78620bfb2decae1c3
Successfully built pyq
Installing collected packages: pyq
Successfully installed pyq-4.1.2
(pyq) $ pyq --versions
Welcome to kdb+ 32bit edition
For support please see http://groups.google.com/d/forum/personal-kdbplus
Tutorials can be found at http://code.kx.com/q
To exit, type \\
To remove this startup msg, edit q.q
PyQ 4.1.2
KDB+ 3.5 (2017.11.30) m32
Python 3.6.3 (v3.6.3:2c5fed86e0, Oct  3 2017, 00:32:08) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
(pyq) $ brew
-bash: brew: command not found