关于python:如何为python3安装virtualenv?

How to install virtualenv for python3?

我正在创建一个Django应用程序并坚持virtualenv安装。 我已经看到了这一点,并试图遵循,但每次我尝试的东西都会导致这种情况。 为什么不能使用python 3进行安装,但这可以工作virtualenv venv但是它安装了python 2.我该怎么办?

1
2
3
4
5
6
7
8
9
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

1
2
3
4
5
6
7
8
9
10
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


像debian这样的debian可以使用python3-venv

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

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

编辑:

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

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

conda create --name $ENVIRONMENT_NAME python