nnpy
nnpy copied to clipboard
OSError: cannot load library libnanomsg.so.5.0.0
nnpy
install fails with the following traceback
$ sudo pip install nnpy
Downloading/unpacking nnpy
Downloading nnpy-1.3.tar.gz
Running setup.py (path:/tmp/pip_build_root/nnpy/setup.py) egg_info for package nnpy
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_root/nnpy/setup.py", line 28, in <module>
install_requires=['cffi'],
File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 318, in __init__
_Distribution.__init__(self, attrs)
File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 376, in finalize_options
ep.load()(self, ep.name, value)
File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 187, in cffi_modules
add_cffi_module(dist, cffi_module)
File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 49, in add_cffi_module
execfile(build_file_name, mod_vars)
File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 25, in execfile
exec(code, glob, glob)
File "generate.py", line 119, in <module>
ffi = create_module()
File "generate.py", line 115, in create_module
f.write(symbols(ffi, host_library))
File "generate.py", line 56, in symbols
nanomsg = ffi.dlopen(host_library)
File "/usr/local/lib/python2.7/dist-packages/cffi/api.py", line 139, in dlopen
lib, function_cache = _make_ffi_library(self, name, flags)
File "/usr/local/lib/python2.7/dist-packages/cffi/api.py", line 769, in _make_ffi_library
backendlib = _load_backend_lib(backend, libname, flags)
File "/usr/local/lib/python2.7/dist-packages/cffi/api.py", line 764, in _load_backend_lib
return backend.load_library(path, flags)
OSError: cannot load library libnanomsg.so.5.0.0: libnanomsg.so.5.0.0: cannot open shared object file: No such file or directory
nanomsg is installed in /usr/local/lib/x86_64-linux-gnu/
:
$ ls -la /usr/local/lib/x86_64-linux-gnu/
total 400
drwxr-xr-x 3 root root 4096 Nov 7 20:29 .
drwxr-xr-x 6 root root 4096 Nov 4 13:53 ..
lrwxrwxrwx 1 root root 19 Nov 4 13:53 libnanomsg.so -> libnanomsg.so.5.0.0
-rw-r--r-- 1 root root 395509 Nov 7 20:28 libnanomsg.so.1.0.0
lrwxrwxrwx 1 root root 19 Nov 4 13:53 libnanomsg.so.5.0.0 -> libnanomsg.so.1.0.0
drwxr-xr-x 2 root root 4096 Nov 7 20:29 pkgconfig
LD_LIBRARY_PATH
points to that location (I also have https://github.com/tonysimpson/nanomsg-python installed and previously it failed to install without this env var):
export LD_LIBRARY_PATH=/usr/local/lib/x86_64-linux-gnu/
Code fails on the line https://github.com/nanomsg/nnpy/blob/1.3/generate.py#L56, I tried to dig a bit deeper, it seems like shared library is found by ctypes.util.find_library
but fails to load.
$ sudo python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes.util
>>> ctypes.util.find_library('nanomsg')
'libnanomsg.so.5.0.0'
$ sudo pip freeze | grep cffi
cffi==1.9.1
I also tried with cffi==1.8.3
- same issue.
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.4 LTS
Release: 14.04
Codename: trusty
Any idea how to fix this?
Not really. Ask the cffi guys on IRC or their mailing list, maybe?
Hit the same problem a few days ago. Known issue. https://bitbucket.org/cffi/cffi/issues/219/ld_library_path-is-ignored-by-dlopen
My current workaround is to drop a site.cfg in nnpy and set host_library to the absolute full path of my libnanomsg.so. Also, if you pass rpath to pip, you don't need LD_LIBRARY_PATH at runtime. But on OSX, pip doesn't actually implement rpath. You'll have to use install_name_tool to add it to the generated .so manually.
It would be nice if nnpy can support bundled lib like zeromq does. https://pypi.python.org/pypi/pyzmq-static https://github.com/zeromq/pyzmq/pull/205
And do we support python wheels? I saw some for zeromq. https://pypi.python.org/pypi/pyzmq/ But none for nnpy.
Known issue
looks different to me - ctypes.util.find_library
finds the library in my case, is fails afterwards. but thanks for the reference.
There's no intrinsic reason we don't have wheels, no; I think I looked at it once but it looked kind of tricky, so I didn't have much motivation to continue. I think it would be an improvement, but I'm not sure I have much time to spend on it. I also don't really have access to a Windows environment if people wanted wheels for Windows, but I could do Linux and macOS if I had the proper procedure/code in place.
reference:http://www.cnblogs.com/qq952693358/p/6375211.html i tried OK.