成功后执行导入错误pip install compilation

时间:2017-07-27 14:28:41

标签: python ubuntu pip pypy crossbar

我的麻烦

在干净的Ubuntu 16.04环境中,我想安装并使用Crossbar.io。

我已经从ppa,virtualenv 安装了pypy并激活了一个新的pypy virtualenv。

我在通过命令pip install crossbar安装crossbar时遇到了一些错误,但使用此构建命令解决了这个错误:

pip install --no-cache-dir --global-option=build_ext --global-option="-I/usr/include/python2.7" crossbar

现在,当使用crossbar version启动crossbar时出现以下错误:

Traceback (most recent call last):
  File "/home/visiboost/gmm_pypy_env2/bin/crossbar", line 11, in <module>
    load_entry_point('crossbar==17.6.1.post3', 'console_scripts', 'crossbar')()
  File "/home/visiboost/gmm_pypy_env2/site-packages/pkg_resources/__init__.py", line 542, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/home/visiboost/gmm_pypy_env2/site-packages/pkg_resources/__init__.py", line 2569, in load_entry_point
    return ep.load()
  File "/home/visiboost/gmm_pypy_env2/site-packages/pkg_resources/__init__.py", line 2229, in load
    return self.resolve()
  File "/home/visiboost/gmm_pypy_env2/site-packages/pkg_resources/__init__.py", line 2235, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/visiboost/gmm_pypy_env2/site-packages/crossbar/controller/cli.py", line 62, in <module>
    from crossbar.controller.node import _read_release_pubkey, _read_node_pubkey
  File "/home/visiboost/gmm_pypy_env2/site-packages/crossbar/controller/node.py", line 44, in <module>
    from nacl.signing import SigningKey
  File "/home/visiboost/gmm_pypy_env2/site-packages/nacl/signing.py", line 19, in <module>
    import nacl.bindings
  File "/home/visiboost/gmm_pypy_env2/site-packages/nacl/bindings/__init__.py", line 17, in <module>
    from nacl.bindings.crypto_box import (
  File "/home/visiboost/gmm_pypy_env2/site-packages/nacl/bindings/crypto_box.py", line 18, in <module>
    from nacl._sodium import ffi, lib
ImportError: unable to load extension module '/home/visiboost/gmm_pypy_env2/site-packages/nacl/_sodium.pypy-41-x86_64-linux-gnu.so': /home/visiboost/gmm_pypy_env2/site-packages/nacl/_sodium.pypy-41-x86_64-linux-gnu.so: undefined symbol: _Py_NoneStruct

我尝试在启动之前按设置环境变量添加路径,但没有成功:

export LD_LIBRARY_PATH=/usr/lib/python2.7/config-x86_64-linux-gnu/:/usr/lib/x86_64-linux-gnu/

我的环境

  • Ubuntu 16.04 / 4.4.0-87-generic
  • Python 2.7.13(5.8.0 + dfsg-2~ppa2~ubuntu16.04,2017年6月17日,18:50:19)
  • [PyPy 5.8.0 with GCC 5.4.0 20160609]
  • 来自/ home / visiboost / gmm_pypy_env2 / site-packages(python 2.7)的
  • pip 9.0.1

ldd对失败库的结果:

ldd -r /home/visiboost/gmm_pypy_env2/site-packages/nacl/_sodium.pypy-41-x86_64-linux-gnu.so
    linux-vdso.so.1 =>  (0x00007fff31ddd000)
    libsodium.so.18 => /usr/lib/x86_64-linux-gnu/libsodium.so.18 (0x00007fe336153000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe335f0c000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe335b41000)
    /lib64/ld-linux-x86-64.so.2 (0x0000564659a68000)
undefined symbol: _Py_NoneStruct    (/home/visiboost/gmm_pypy_env2/site-packages/nacl/_sodium.pypy-41-x86_64-linux-gnu.so)
undefined symbol: PyObject_CallMethod   (/home/visiboost/gmm_pypy_env2/site-packages/nacl/_sodium.pypy-41-x86_64-linux-gnu.so)
undefined symbol: PyEval_RestoreThread  (/home/visiboost/gmm_pypy_env2/site-packages/nacl/_sodium.pypy-41-x86_64-linux-gnu.so)
undefined symbol: PyLong_FromVoidPtr    (/home/visiboost/gmm_pypy_env2/site-packages/nacl/_sodium.pypy-41-x86_64-linux-gnu.so)
undefined symbol: PyArg_UnpackTuple (/home/visiboost/gmm_pypy_env2/site-packages/nacl/_sodium.pypy-41-x86_64-linux-gnu.so)
undefined symbol: PyErr_Occurred    (/home/visiboost/gmm_pypy_env2/site-packages/nacl/_sodium.pypy-41-x86_64-linux-gnu.so)
undefined symbol: PyImport_ImportModule (/home/visiboost/gmm_pypy_env2/site-packages/nacl/_sodium.pypy-41-x86_64-linux-gnu.so)
undefined symbol: PyLong_FromUnsignedLong   (/home/visiboost/gmm_pypy_env2/site-packages/nacl/_sodium.pypy-41-x86_64-linux-gnu.so)
undefined symbol: PyInt_FromLong    (/home/visiboost/gmm_pypy_env2/site-packages/nacl/_sodium.pypy-41-x86_64-linux-gnu.so)
undefined symbol: PyEval_SaveThread (/home/visiboost/gmm_pypy_env2/site-packages/nacl/_sodium.pypy-41-x86_64-linux-gnu.so)

你有什么想法吗?

2 个答案:

答案 0 :(得分:1)

您不应该使用ppyy的cpython标头,因此--global-option="-I/usr/include/python2.7"是错误的。正如文档herehere所示,您可能需要安装pypy-dev包,以便您可以使用pypy构建包,就像您需要python-dev一样 用python构建包。

编辑:查看横杆documentation,他们根本不建议使用apt get,还建议从源代码编译CPython,这就是为什么没有提到python-dev封装

答案 1 :(得分:0)

使用@mattip响应解决:通过apt-get install pypy-dev安装pypy-dev软件包并再次运行pip install以使用良好的库pip install --no-cache-dir crossbar重建模块。

现在它对我有用了!