简体   繁体   English

python:加载共享库时出错:libpython3.4m.so.1.0:无法打开共享对象文件:没有这样的文件或目录

[英]python: error while loading shared libraries: libpython3.4m.so.1.0: cannot open shared object file: No such file or directory

I have created a python virtual environment using virtualenv , after activating it, I can see where is Python installed in my shell as following:我使用virtualenv创建了一个 python 虚拟环境,激活它后,我可以看到 Python 安装在我的 shell 中的位置,如下所示:

(virtualenv-test) bash-4.1$ whereis python
python: /usr/bin/python2.6 /usr/bin/python2.6-config /usr/bin/python
/usr/lib/python2.6 /usr/lib64/python2.6 /usr/X11R6/bin/python2.6
/usr/X11R6/bin/python2.6-config /usr/X11R6/bin/python
/usr/bin/X11/python2.6 /usr/bin/X11/python2.6-config
/usr/bin/X11/python /usr/include/python2.6
/usr/share/man/man1/python.1.gz

Also I can see what python version I'm using:我也可以看到我正在使用什么 python 版本:

(virtualenv-test) bash-4.1$ which python
/data/virtualenv-test/bin/python

However, after typing python, I got the following error message:但是,在键入 python 后,我收到以下错误消息:

(virtualenv-test) bash-4.1$ python
python: error while loading shared libraries: libpython3.4m.so.1.0: cannot open shared object file: No such file or directory

What can be the underlying reason?根本原因是什么?

Try adding the python3.4's lib path to the $LD_LIBRARY_PATH environment variable.尝试将 python3.4 的 lib 路径添加到$LD_LIBRARY_PATH环境变量中。

First find out the lib path of python3.4 (depends on how you installed python3.4)首先找出python3.4的lib路径(取决于你是如何安装python3.4的)

For me it was: /opt/python361/lib , then add it to environment variable like so:对我来说是: /opt/python361/lib ,然后将其添加到环境变量中,如下所示:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/python361/lib

PS I came across a similar problem while using virtualenv with python3.6 , and I fixed it like so: PS我在使用virtualenvpython3.6时遇到了类似的问题,我像这样修复了它:

  • First, append include <lib path of python3.x> to /etc/ld.so.conf (Something like: include /opt/python361/lib or include /usr/local/lib )首先,将include <lib path of python3.x>附加到/etc/ld.so.conf (类似于: include /opt/python361/libinclude /usr/local/lib
  • Then, activate the new configuration by running sudo /sbin/ldconfig -v .然后,通过运行sudo /sbin/ldconfig -v激活新配置。

Another way is adding LDFLAGS="-Wl,-rpath /usr/local/lib" in configure, for example另一种方法是在配置中添加LDFLAGS="-Wl,-rpath /usr/local/lib" ,例如

./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"

/usr/local/lib is the path where libpython3.*.so files are in /usr/local/liblibpython3.*.so文件所在的路径

对于 Python 3.6,它被修复了

sudo apt-get install libpython3.6-dev

export LD_LIBRARY_PATH=[your python path to libpython3.4m.so]

libpython3.4m.so is under your python source from which you built it. libpython3.4m.so位于您构建它的 python 源下。

Put it in your .bashrc to set it at login automatically.将它放在您的 .bashrc 中以在登录时自动设置它。

I can't force virtualenv to 3.4 on my machine but you can see that under lib of your virtualenv there's just a bunch of symlink to your local python installation.我无法在我的机器上将 virtualenv 强制为 3.4,但是您可以看到在您的 virtualenv 的lib下,只有一堆指向本地 python 安装的符号链接。 I guess libpython3.4m.so is fetch by one of those.我猜libpython3.4m.so是由其中之一获取的。

Kudos to above, For python 3.X you can fix this issue with:感谢以上,对于python 3.X,您可以通过以下方式解决此问题:

sudo apt-get install libpython3.x-dev

No need to any changes to environment path manually.无需手动更改环境路径。

For me, libpython3.6m.so.1.0 was in the folder where I downloaded Python source ( ~/Python3.6.9 ).对我来说, libpython3.6m.so.1.0位于我下载 Python 源代码 ( ~/Python3.6.9 ) 的文件夹中。

I simply did : sudo cp ~/Python3.6.9/libpython3.6m.so.1.0 /usr/local/lib/python3.6/我只是做了: sudo cp ~/Python3.6.9/libpython3.6m.so.1.0 /usr/local/lib/python3.6/

and : export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/python3.6和: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/python3.6

On python 3.8, I resolved this by deleting the virtualenv directory ( ./venv in my case) and recreating using python's built-in venv module installed of the pip-installed virtualenv .在 python 3.8 上,我通过删除 virtualenv 目录(在我的例子中是./venv )并使用安装了 pip 安装的virtualenv python 内置venv模块重新创建来解决这个问题。 I'm on arch linux and also first did sudo pacman -Syu .我在 arch linux 上,也首先做了sudo pacman -Syu Python was originally installed using just sudo pacman -S python . Python 最初是使用sudo pacman -S python安装的。

$ rm -r ./venv
$ python -m venv venv
$ . ./venv/bin/activate
$ python --version
Python 3.8.1

This one worked for me.这个对我有用。

cd ~/
vim .bashrc
export LD_LIBRARY_PATH=~/miniconda/envs/python3.6/lib/

我通过安装包来运行它

sudo apt-get install libpython3.x-dev 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 加载共享库时出现 Python 错误:libpython3.5m.so.1.0:无法打开共享对象文件:没有这样的文件或目录 - Python error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory ImportError:libpython3.7m.so.1.0:无法打开共享 object 文件:没有这样的文件或目录 - ImportError: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory Python3.5 导入错误:libpython3.5m.so.1.0:无法打开共享对象文件:没有这样的文件或目录 - Python3.5 ImportError: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory 问:python(在集群的bash脚本中使用cutadapt):libpython3.7m.so.1.0:无法打开共享对象文件:无此类文件或目录 - Q: python (using cutadapt in bash script on cluster): libpython3.7m.so.1.0: cannot open shared object file: No such file or directory Python3.7:加载共享库时出错:libpython3.7m.so.1.0 - Python3.7: error while loading shared libraries: libpython3.7m.so.1.0 ./python:加载共享库时出错:libssl.so.1.1:无法打开共享对象文件:没有这样的文件或目录 - ./python: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory ImportError: libpython3.8.so.1.0: 无法打开共享对象文件: 没有那个文件或目录 - ImportError: libpython3.8.so.1.0: cannot open shared object file: No such file or directory Docker:libpython2.7.so.1.0:无法打开共享对象文件:没有这样的文件或目录 - Docker: libpython2.7.so.1.0: cannot open shared object file: No such file or directory libpython2.7.so.1.0:无法打开共享对象文件:没有这样的文件或目录 - libpython2.7.so.1.0: cannot open shared object file: No such file or directory pyinstaller 错误:OSError:找不到 Python 库:libpython3.4mu.so.1.0、libpython3.4m.so.1.0、libpython3.4.so.1.0 - pyinstaller error: OSError: Python library not found: libpython3.4mu.so.1.0, libpython3.4m.so.1.0, libpython3.4.so.1.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM