python-libzmq: import zmq fails in python2 on Xenial
On Ubuntu Xenial (upgraded from Trusty), in python 2.7.12, with python-libzmq installed, import zmq fails with the following error message:
ImportError: libzmq.so.3: cannot open shared object file: No such file or directory
Creating a symbolic link in /usr/lib/
ln -s libzmq.so.5.0.0 libzmq.so.3
seems to fix the issue. Is this a bug in python-zmq or in libzmq3?
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Ubuntu pyzmq Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Damjan Miklic
- Solved:
- Last query:
- Last reply:
Revision history for this message
|
#1 |
What is the output of:
sudo updatedb; locate libzmq*
Thanks
Revision history for this message
|
#2 |
Hi, thanks for the quick reply.
For some reason, the command
sudo updatedb; locate libzmq*
provides absolutely no output on my system.
Leaving out the trailing asterisk:
sudo updatedb; locate libzmq
provides the following output:
/home/damjan/
/home/damjan/
/home/damjan/
/home/damjan/
/home/damjan/
/home/damjan/
/home/damjan/
/home/damjan/
/home/damjan/
/home/damjan/
/home/damjan/
/home/damjan/
/home/damjan/
/home/damjan/
/home/damjan/
/home/damjan/
/home/damjan/
/home/damjan/
/home/damjan/
/home/damjan/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/ext/
/mnt/storage/
/usr/lib/
/usr/lib/
/usr/lib/
/usr/lib/
/usr/lib/
/usr/lib/
/usr/lib/
/usr/lib/
/usr/lib/
/usr/lib/
/usr/lib/
/usr/local/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/var/cache/
/var/cache/
/var/cache/
/var/cache/
/var/cache/
/var/cache/
/var/lib/
/var/lib/
/var/lib/
/var/lib/
/var/lib/
/var/lib/
/var/lib/
/var/lib/
/var/lib/
/var/lib/
/var/lib/
/var/lib/
/var/lib/
/var/lib/
/var/lib/
/var/lib/
/var/lib/
The file /usr/lib/
The /home/damjan/
dpkg-query -L libzmq3-dev
gives:
/.
/usr
/usr/lib
/usr/lib/
/usr/lib/
/usr/lib/
/usr/lib/
/usr/include
/usr/include/
/usr/include/zmq.h
/usr/include/
/usr/share
/usr/share/doc
/usr/share/
/usr/share/
/usr/share/man
/usr/share/man/man7
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/man/man3
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/lib/
/usr/share/
Revision history for this message
|
#3 |
libzmq*3* seems to be a leftover from trusty, xenial has libzmq*5*
What output do you get for
apt-get --simulate autoremove
Revision history for this message
|
#4 |
Here is the output of sudo apt-get --simulate autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
ipython-
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
Remv ipython-
Remv libjs-highlight [8.2+ds-4build1]
Remv libjs-highlight.js [8.2+ds-4build1]
Remv libjs-marked [0.3.2+dfsg-1]
As for libzmq*3*, apt-cache search libzmq gives
libjeromq-java - Java implementation of the ZeroMQ messaging library
libzeromq-perl - messaging library using ZeroMQ
libzmq-dbg - lightweight messaging kernel (debugging symbols)
libzmq-dev - lightweight messaging kernel (development files)
libzmq-java - ZeroMQ Java bindings (jzmq)
libzmq-java-doc - Documentation for ZeroMQ Java bindings (jzmq)
libzmq-jni - ZeroMQ Java bindings (jzmq)
libzmq1 - lightweight messaging kernel (shared library)
libzmq3-dev - lightweight messaging kernel (development files)
libzmq5 - lightweight messaging kernel (shared library)
libzmq5-dbg - lightweight messaging kernel (debugging symbols)
libzmqpp-dev - High-level C++ bindings for zeromq3 - development files
libzmqpp3 - High-level C++ bindings for zeromq3
and apt-cache show libzmq3-dev gives
Package: libzmq3-dev
Priority: optional
Section: universe/libdevel
Installed-Size: 1404
Maintainer: Ubuntu Developers <email address hidden>
Original-
Architecture: amd64
Source: zeromq3
Version: 4.1.4-7
Replaces: libzmq5-dev
Provides: libzmq5-dev
Depends: libzmq5 (= 4.1.4-7)
Conflicts: libzmq-dev, libzmq5-dev
Filename: pool/universe/
Size: 282046
MD5sum: 5c421215f8fd6ae
SHA1: 043821803a86bbb
SHA256: a618309da599c35
Description-en: lightweight messaging kernel (development files)
ØMQ is a library which extends the standard socket interfaces with features
traditionally provided by specialised messaging middleware products.
.
ØMQ sockets provide an abstraction of asynchronous message queues, multiple
messaging patterns, message filtering (subscriptions), seamless access to
multiple transport protocols and more.
.
This package contains the ZeroMQ development libraries and header files.
Description-md5: 7b2c1e47f6d3055
Multi-Arch: same
Homepage: http://
Bugs: https:/
Origin: Ubuntu
Supported: 9m
Best,
damjan
Revision history for this message
|
#5 |
What is the output of
apt-cache policy libzmq-dev libzmq3-dev libzmq5-dev libzmq3 libzmq5
Revision history for this message
|
#6 |
And please also provide the output of
dpkg -l | grep zmq
Revision history for this message
|
#7 |
Here are the outputs.
apt-cache policy libzmq-dev libzmq3-dev libzmq5-dev libzmq3 libzmq5
libzmq-dev:
Installed: (none)
Candidate: 2.2.0+dfsg-7
Version table:
2.2.0+dfsg-7 500
500 http://
libzmq3-dev:
Installed: 4.1.4-7
Candidate: 4.1.4-7
Version table:
*** 4.1.4-7 500
500 http://
100 /var/lib/
libzmq5-dev:
Installed: (none)
Candidate: (none)
Version table:
libzmq3:
Installed: (none)
Candidate: (none)
Version table:
4.0.4+dfsg-2 0
100 /var/lib/
libzmq5:
Installed: 4.1.4-7
Candidate: 4.1.4-7
Version table:
*** 4.1.4-7 500
500 http://
100 /var/lib/
dpkg -l | grep zmq
rc libzmq1:amd64 2.2.0+dfsg-5 amd64 lightweight messaging kernel (shared library)
rc libzmq3:amd64 4.0.4+dfsg-2 amd64 lightweight messaging kernel (shared library)
ii libzmq3-dev:amd64 4.1.4-7 amd64 lightweight messaging kernel (development files)
ii libzmq5:amd64 4.1.4-7 amd64 lightweight messaging kernel (shared library)
ii libzmqpp-dev:amd64 3.2.0-0ubuntu4 amd64 High-level C++ bindings for zeromq3 - development files
ii libzmqpp3:amd64 3.2.0-0ubuntu4 amd64 High-level C++ bindings for zeromq3
ii python-zmq 15.2.0-0ubuntu4 amd64 Python bindings for 0MQ library
ii python3-zmq 15.2.0-0ubuntu4 amd64 Python3 bindings for 0MQ library
Revision history for this message
|
#8 |
What do you get for the commands
ls -l /usr/lib/
ldd /usr/lib/
As shown on http://
You could try deleting (or renaming) the /usr/lib/
Maybe you have to reinstall libzmq3-dev, libzmq5 and/or python-zmq afterwards, and/or update the loader cache.
Revision history for this message
|
#9 |
Hi Manfred,
thanks for helping me with this. Like I wrote in my original report, libzmq.so.3 was not installed by any package, and that was my original problem, because without it, I could not import zmq in Python 2. So I created libzmq.so.3 by hand as a symlink to libzmq.so which allows me to import zmq in Python 2.
So to sum up, I installed python-zmq with apt, which pulled in libzmq5. However, it did not function properly until I created libzmq.so.3 by hand, which does not seem like proper behavior.
The output of ls -l /usr/lib/
-rw-r--r-- 1 root root 1244438 Mar 15 2016 /usr/lib/
lrwxrwxrwx 1 root root 17 Mar 14 2016 /usr/lib/
lrwxrwxrwx 1 root root 17 Mar 14 2016 /usr/lib/
-rw-r--r-- 1 root root 60208 Mar 14 2016 /usr/lib/
lrwxrwxrwx 1 root root 15 Mar 15 2016 /usr/lib/
lrwxrwxrwx 1 root root 9 Dec 13 19:16 /usr/lib/
lrwxrwxrwx 1 root root 15 Mar 15 2016 /usr/lib/
-rw-r--r-- 1 root root 416880 Mar 15 2016 /usr/lib/
and for ldd /usr/lib/
linux-vdso.so.1 => (0x00007fffd3d6
libsodium.so.18 => /usr/lib/
librt.so.1 => /lib/x86_
libpthread.so.0 => /lib/x86_
libstdc++.so.6 => /usr/lib/
libc.so.6 => /lib/x86_
libgcc_s.so.1 => /lib/x86_
/lib64/
libm.so.6 => /lib/x86_
Thanks and best,
damjan
Revision history for this message
|
#10 |
So to sum up:
You had problems with "python import zmq", and no one knows why.
As a workaround you created a symlink for a file that should not be needed on xenial, and now it works, and no one knows why.
Revision history for this message
|
#11 |
Ok, I've figured it out :) I had a previous version of pyzmq installed by pip. I should have posted the full Python error message, as it gives the clue to the solution (the pip version is installed in /usr/local):
damjan@
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import zmq
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/
from zmq import backend
File "/usr/local/
reraise(
File "/usr/local/
_ns = select_
File "/usr/local/
mod = __import__(name, fromlist=
File "/usr/local/
from . import (constants, error, message, context,
ImportError: libzmq.so.3: cannot open shared object file: No such file or directory
Thanks for your help!
Best,
damjan