Installing a python module with pip (pyzmq)

Hello.

I have been trying to install pyzmq (https://github.com/zeromq/pyzmq) on my OpenWrt router, using pip.

However, I can't succeed. I've tried the following:


  • With pip install pyzmq, the terminal throws an error:

ERROR: Command errored out with exit status 1: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-MJUq6m/pyzmq/setup.py'"'"'; __file__='"'"'/tmp/pip-install-MJUq6m/pyzmq/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-cN3XAz/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

I don't understand what it means and when I go to /var/log, there is no information there (I don't know if it is the right place to search for the log, anyway).


/home/inesmll/Downloads/openwrt-sdk-18.06.2-x86-64_gcc-7.3.0_musl.Linux-x86_64/include/toplevel.mk:209: recipe for target 'world' failed make: *** [world] Error 1

Note: I downloaded the folder of the sdk, executed ./scripts/feeds update -a and ./scripts/feeds install -a and then typed make menuconfig (I checked that python was selected). Finally, I run make.


  • Installing using the source code, by executing python setup.py install. However, it throws an error in the end:

(...) Using bundled libzmq fetching https://github.com/zeromq/libzmq/releases/download/v4.3.2/zeromq-4.3.2.tar.gz into bundled error: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727)> (...)

Although I don't know what it means, this solution would not work anyway, because pyzmq uses Cython, and thus I would need a C compiler, not present in the router.


  • I've also installed pyzmq on my computer and then moved the folder "pyzmq-18.1.0.dist-info" from "site-packages" to the "site-packages" folder in the OpenWrt router. However, the lib is still not recognized.

Note: both the router and my computer have the same architecture (x86_64) and libzmq-nc is installed on the router. Also, I am required to use python on my solution.

Nothing works, I don't know what else to do...

If you guys can't solve this problem, could you please suggest me another queueing system that is easier to install on OpenWrt? My preference is zeromq because it is distributed, but I'm open to other solutions.

I've also installed pyzmq on my computer and then moved the folder "pyzmq-18.1.0.dist-info" from "site-packages" to the "site-packages" folder in the OpenWrt router. However, the lib is still not recognized.

The actual library should be located under "site-packages/zmq". Try copying this directory instead.

Ok, I've done as you said and it is now recognized by the python interpreter! However, it threw an error:

ImportError: cannot import name 'constants' from 'zmq.backend.cython' (/usr/lib/python3.7/site-packages/zmq/backend/cython/__init__.py)

This is probably not the best solution for the problem... And I don't know how to cross compile (using SDK, for instance) a package meant for pip. I only know how to cross compile with Makefiles.

I am confused as to which python version you are using. Your original pip install pyzmq error was from python2, and the last error is from python3.7. Can you check if python3.7 -m pip install -U pyzmq leads to the same error as in your original post?

You are right, I should have stick with only one version in my question. I tried all steps with both python2 and 3, that's why the outputs are mixed with both.

Anyway, I did as you said:

root@OpenWrt:~# python3.7 -m pip install -U pyzmq

Collecting pyzmq Using cached https://files.pythonhosted.org/packages/7a/d2/1eb3a994374802b352d4911f3317313a5b4ea786bc830cc5e343dad9b06d/pyzmq-18.1.0.tar.gz Installing collected packages: pyzmq Running setup.py install for pyzmq ... error

ERROR: Command errored out with exit status 1: /usr/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-pfu85w3m/pyzmq/setup.py'"'"'; __file__='"'"'/tmp/pip-install-pfu85w3m/pyzmq/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-qa9di8co/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

same error :confused:

Too bad. I was hoping there was something wrong with the python version. Sorry, I am out of ideas now.

I think it would be easier to avoid cython and cross-compilation, and pick a pure-python queue library instead.