首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在新环境中构建cython扩展:找不到/lib/libpthread.so.0

在新环境中构建cython扩展:找不到/lib/libpthread.so.0
EN

Stack Overflow用户
提问于 2020-02-19 10:20:47
回答 1查看 510关注 0票数 0

我正在尝试部署一个使用一些cython扩展的包。我已经编写了以下设置脚本:

代码语言:javascript
运行
复制
import os
import sys
from setuptools import setup, Extension

# factory function
def my_build_ext(pars):
    # import delayed:
    from setuptools.command.build_ext import build_ext as _build_ext

    # include_dirs adjusted: 
    class build_ext(_build_ext):
        def finalize_options(self):
            _build_ext.finalize_options(self)
            # Prevent numpy from thinking it is still in its setup process:
            __builtins__.__NUMPY_SETUP__ = False
            import numpy
            self.include_dirs.append(numpy.get_include())

    #object returned:
    return build_ext(pars)

# cython c++ extensions
extnames = [
    'npextc',
    'intquickheapdict',
    'FixedOrderedIntDict'
    ]

...

PATHADD = 'vemomoto_core/npcollections/'
PACKAGEADD = PATHADD.replace("/", ".")

ext = '.pyx'

extensions = [Extension(PACKAGEADD+name, [PATHADD+name+ext],
                        extra_compile_args=['-std=c++11', '-O3']+parcompileargs,
                        extra_link_args=parlinkargs,
                        )
              for name in extnames]
for e in extensions:
    e.language_level = 3
    e.language = 'c++'

setup(
    name="vemomoto_core_npcollections",
    version="0.9.0.a7",
    cmdclass={'build_ext' : my_build_ext},
    setup_requires=['numpy', 'setuptools>=18.0'],
    install_requires=['numpy', 'scipy'], 
    python_requires='>=3.6',
    packages=['vemomoto_core', PACKAGEADD[:-1]],
    ext_modules=extensions,
    package_data={
        '': ['*.pxd', '*.pyx', '*.c', '*.cpp'],
    },
    zip_safe=False,
)

当我通过在setup.py目录中执行pip install .来构建包时,只要我在我的默认环境中工作,一切都可以正常工作。然而,当我在一个新的测试环境中测试这个过程时,我得到了错误

代码语言:javascript
运行
复制
    /home/user/anaconda3/envs/test37/compiler_compat/ld: cannot find /lib/libpthread.so.0
    /home/user/anaconda3/envs/test37/compiler_compat/ld: cannot find /usr/lib/libpthread_nonshared.a
    collect2: error: ld returned 1 exit status
    error: command 'g++' failed with exit status 1

(完整输出如下所示。)

我假设这里缺少一些依赖项,但我不知道如何找出它是什么,从而如何解决这个错误。我能做些什么?

完整错误消息:

代码语言:javascript
运行
复制
Building wheels for collected packages: vemomoto-core-npcollections                                                                                                                                   [76/1898]
  Building wheel for vemomoto-core-npcollections (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/user/anaconda3/envs/test37/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-0_ns61r9/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-0_ns61r9/se
tup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-4zeu
yeay
       cwd: /tmp/pip-req-build-0_ns61r9/
  Complete output (49 lines):
  /home/user/anaconda3/envs/test37/lib/python3.7/site-packages/setuptools/dist.py:476: UserWarning: Normalizing '0.9.0.a1' to '0.9.0a1'
    normalized_version,
  running bdist_wheel
  running build
  running build_py
  package init file 'vemomoto_core/__init__.py' not found (or not a regular file)
  creating build
  creating build/lib.linux-x86_64-3.7
  creating build/lib.linux-x86_64-3.7/vemomoto_core
  creating build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/_setup_npextc.py -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/sparse3d.py -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/_setup_FixedOrderedIntDict.py -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/_FixedOrderedIntDict_reduce.py -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/__init__.py -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections                                                                                                      copying vemomoto_core/npcollections/_setup_intquickheapdict.py -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections                                                                                       copying vemomoto_core/npcollections/npext.py -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/_npextc_utils.py -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/__init__.pxd -> build/lib.linux-x86_64-3.7/vemomoto_core
  copying vemomoto_core/npcollections/FixedOrderedIntDict.pxd -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/npextc.pxd -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/intquickheapdict.pxd -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/intquickheapdict.pyx -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections                                                                                             copying vemomoto_core/npcollections/npextc.pyx -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/FixedOrderedIntDict.pyx -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/heapoperations_c.c -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/sectionsum.c -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections                                                                                                     copying vemomoto_core/npcollections/intquickheapdict.cpp -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections                                                                                             copying vemomoto_core/npcollections/FixedOrderedIntDict.cpp -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/npextc.cpp -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  running build_ext
  building 'vemomoto_core.npcollections.npextc' extension
  creating build/temp.linux-x86_64-3.7
  creating build/temp.linux-x86_64-3.7/vemomoto_core
  creating build/temp.linux-x86_64-3.7/vemomoto_core/npcollections                                                                                                                                               gcc -pthread -B /home/user/anaconda3/envs/test37/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/user/anaconda3/envs/test37/include/python3.7m -I/home/user/anaconda3/envs/test37/lib/python3.7/site-packages/numpy/core/include -c vemomoto_core/npcollections/npextc.cpp -o build/temp.linux-x86_64-3.7/vemomoto_core/npcollections/npextc.o -std=c++11 -O3 -fopenmp
  cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
  In file included from /home/user/anaconda3/envs/test37/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1832:0,
                   from /home/user/anaconda3/envs/test37/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                   from /home/user/anaconda3/envs/test37/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                   from vemomoto_core/npcollections/npextc.cpp:636:
  /home/user/anaconda3/envs/test37/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEP
RECATED_API NPY_1_7_API_VERSION" [-Wcpp]
   #warning "Using deprecated NumPy API, disable it with " \
    ^~~~~~~
  g++ -pthread -shared -B /home/user/anaconda3/envs/test37/compiler_compat -L/home/user/anaconda3/envs/test37/lib -Wl,-rpath=/home/user/anaconda3/envs/test37/lib -Wl,--no-as-needed -Wl,--sysroot=
/ -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections build/temp.linux-x86_64-3.7/vemomoto_core/npcollections/npextc.o -o build/lib.linux-x86_64-3.7/ve
momoto_core/npcollections/npextc.cpython-37m-x86_64-linux-gnu.so -fopenmp
  /home/user/anaconda3/envs/test37/compiler_compat/ld: cannot find /lib/libpthread.so.0
  /home/user/anaconda3/envs/test37/compiler_compat/ld: cannot find /usr/lib/libpthread_nonshared.a
  collect2: error: ld returned 1 exit status
  error: command 'g++' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for vemomoto-core-npcollections
  Running setup.py clean for vemomoto-core-npcollections
Failed to build vemomoto-core-npcollections
EN

回答 1

Stack Overflow用户

发布于 2020-02-20 04:34:34

为了解决这个问题,我比较了新的anaconda环境和我使用的环境。为此,我使用了

代码语言:javascript
运行
复制
conda list

在旧的和新的安装中,并比较输出。然后,我寻找那些包含在旧环境中但不包含在新环境中的包,这些包的名称表明它们可能包含正确的文件。

在安装了候选程序并重新尝试构建后,我发现gxx_linux-64 (对于另一个包cmake)是构建的必要要求。由于这些包在PyPI上似乎不可用,因此我将要求最终用户使用anaconda命令

代码语言:javascript
运行
复制
conda install gxx_linux-64
conda install cmake

在安装我的软件包之前。如果能在设置脚本中包含这个依赖项就好了,但这是另一个问题……

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60292082

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档