如何为python3安装virtualenv?

时间:2016-10-24 19:33:24

标签: python virtualenv

我正在创建一个Django应用程序并坚持使用virtualenv安装。我见过this并试图效仿,但每当我尝试一些东西时它就会产生这种效果。为什么不能使用python 3进行安装,但这有效virtualenv venv但是它安装了python 2.我该怎么办?

virtualenv -p python3 venv
Running virtualenv with interpreter /home/oroborus/anaconda3/bin/python3
Using base prefix '/home/oroborus/anaconda3'
New python executable in venv/bin/python3
Also creating executable in venv/bin/python
venv/bin/python3: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory
ERROR: The executable venv/bin/python3 is not functioning
ERROR: It thinks sys.prefix is '/home/oroborus/PycharmProjects/test-app' (should be '/home/oroborus/PycharmProjects/test-app/venv')
ERROR: virtualenv is not compatible with this system or executable

键入locate libpython3.5

locate libpython3.5
/home/oroborus/anaconda3/envs/tensorflow/lib/libpython3.5m.so
/home/oroborus/anaconda3/envs/tensorflow/lib/libpython3.5m.so.1.0
/home/oroborus/anaconda3/envs/tensorflow/lib/python3.5/config-3.5m/libpython3.5m.a
/home/oroborus/anaconda3/lib/libpython3.5m.so
/home/oroborus/anaconda3/lib/libpython3.5m.so.1.0
/home/oroborus/anaconda3/lib/python3.5/config-3.5m/libpython3.5m.a
/home/oroborus/anaconda3/pkgs/python-3.5.2-0/lib/libpython3.5m.so
/home/oroborus/anaconda3/pkgs/python-3.5.2-0/lib/libpython3.5m.so.1.0
/home/oroborus/anaconda3/pkgs/python-3.5.2-0/lib/python3.5/config-3.5m/libpython3.5m.a

1 个答案:

答案 0 :(得分:2)

像发行版python3-venv这样的debian可用。

使用apt sudo apt-get install python3 python3-venv安装它。

然后像python3 -m venv yourvenvfoldername一样使用它。

修改

在这种情况下使用了anaconda,它对pip和virtualenv都有替换condadocs中提供了很好的命令比较表。

使用conda创建virtualenv可以这样做:

conda create --name $ENVIRONMENT_NAME python