/usr/bin/ld:找不到-lpython3.6m

/usr/bin/ld: cannot find -lpython3.6m

我正在尝试使用 pip 安装 bitarray,但在 linking libpython 期间失败了。

  Downloading https://repo/api/pypi/python/packages/packages/eb/fd/bf67cfea810305148ab8a1e8fbdcc5179f56979c73907fec9a36ebd4a58a/bitarray-1.2.0.tar.gz (48kB)
Installing collected packages: bitarray
    Running setup.py install for bitarray: started
    Running setup.py install for bitarray: finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /opt/rp/python-3.6.9/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-80tjlaa0/bitarray/setup.py'"'"'; __file__='"'"'/tmp/pip-install-80tjlaa0/bitarray/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-lr_6fezd/install-record.txt --single-version-externally-managed --compile
         cwd: /tmp/pip-install-80tjlaa0/bitarray/
    Complete output (19 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    creating build/lib.linux-x86_64-3.6/bitarray
    copying bitarray/__init__.py -> build/lib.linux-x86_64-3.6/bitarray
    copying bitarray/test_bitarray.py -> build/lib.linux-x86_64-3.6/bitarray
    copying bitarray/test_util.py -> build/lib.linux-x86_64-3.6/bitarray
    copying bitarray/util.py -> build/lib.linux-x86_64-3.6/bitarray
    running build_ext
    building 'bitarray._bitarray' extension
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/bitarray
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -O -m64 -fPIC -I/opt/rp/python-3.6.9/include/python3.6m -c bitarray/_bitarray.c -o build/temp.linux-x86_64-3.6/bitarray/_bitarray.o
    gcc -pthread -shared -m64 -Wl,-R/home/jenkins/workspace/python-centos7/python-3.6.9/lib,-R/opt/rp/mysql/lib build/temp.linux-x86_64-3.6/bitarray/_bitarray.o -L/home/jenkins/workspace/centos7/python-3.6.9/lib -lpython3.6m -o build/lib.linux-x86_64-3.6/bitarray/_bitarray.cpython-36m-x86_64-linux-gnu.so
    /usr/bin/ld: cannot find -lpython3.6m
    collect2: error: ld returned 1 exit status
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /opt/alu-rp/python-3.6.9/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-80tjlaa0/bitarray/setup.py'"'"'; __file__='"'"'/tmp/pip-install-80tjlaa0/bitarray/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-lr_6fezd/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

但我可以看到 Libpython.so 个文件

/opt/rp/python-3.6.9/lib/libpython3.6m.so.1.0
/opt/rp/python-3.6.9/lib/libpython3.6m.so
/opt/rp/python-3.6.9/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6m.a

而我的 $LD_LIBRARY_PATH/opt/rp/python-3.6.9/lib:/opt/rp/mysql/lib:/opt/rp/python-3.6.9/lib:/opt/rp/mysql/lib

如何linklibpython安装完成

我认为您需要在 LIBRARY_PATH 以及 LD_LIBRARY_PATH 中包含 libpython3.6m.so 目录。前者在 link 次搜索。后者在运行时间。

我尝试了所有的方法,但没有解决问题。

已解决:libpython3.6m.so 软链接到默认 LD_LIBRARY_PATH 之一。