Anaconda Python虚拟环境在Windows子系统Linux(Ubuntu 14.04)上找不到libpython3.5m.so.1.0。

8

我在Windows周年更新Linux子系统(WSL)上使用Anaconda 4.1.1安装了Python 3.5.2,该子系统基本上是嵌入式的Ubuntu 14.04.5 LTS。

我使用以下命令安装了virtualenv:

pip install virtualenv

然后我尝试在~/temp目录下创建一个虚拟环境:

user@host:~$ virtualenv ~/temp/test
Using base prefix '/home/user/anaconda3'
New python executable in /home/user/temp/test/bin/python
/home/user/temp/test/bin/python: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory
ERROR: The executable /home/user/temp/test/bin/python is not functioning
ERROR: It thinks sys.prefix is '/home/user' (should be '/home/user/temp/test')
ERROR: virtualenv is not compatible with this system or executable

很容易认为这只是WSL的问题,但到目前为止一切都正常,我已经看到类似的错误在Ubuntu上报告过。有什么想法这个问题是什么?


我认为你需要传递“-p python3”选项来告诉“virtualenv”你想要Python 3解释器,即尝试“virtualenv ~/temp/test -p python3”,看看是否改变了情况。 - edwinksl
不行,添加“-p python3”没有改变任何东西。 - Garret Wilson
1
Anaconda 建议您使用 conda 创建环境。同时请参阅 anaconda-issues - brennan
1
@bren,我们都有自己的偏好,你甚至可以说conda比pip更好,我也不会反驳。但这是一个单独的问题。你没有解决问题,你提供的链接也没有解决问题——即使它有关于哪个工具更好的评论。问题是关于pip导致错误的原因——而不是是否有人喜欢除了pip之外的其他工具。 - Garret Wilson
本意是发布此问题 - brennan
2个回答

22

我没有遇到过同样的问题,也没有尝试复制WSL环境。但通常当其他库出现类似问题时,这很可能是配置不良的环境造成的。你需要检查你的库路径:

echo $LD_LIBRARY_PATH

确保包含 libpython 的目录存在。如果不存在:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/the/py/lib/dir
将以下内容翻译为中文:

Add this last line to your .bash_profile or .bashrc to make it permanent.

将这行代码添加到你的.bash_profile 或者 .bashrc 文件中,以使其永久生效。

4
就这样了!我在我的.bashrc文件中添加了export LD_LIBRARY="$LD_LIBRARY_PATH:$HOME/anaconda3/lib",现在virtualenv可以工作了。非常感谢! - Garret Wilson

2

我的解决方案:

打开一个 shell(命令行界面)

cd
vim .bashrc

添加一行

export LD_LIBRARY_PATH=~/anaconda3/lib

或者export LD_LIBRARY_PATH=~/miniconda3/lib - mimoralea

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接