我想在虚拟环境中使用其他python版本。我通常创建一个新环境并设置所需的python版本。但是现在,在我正在使用的新机器上,它不起作用。我用python3.5安装了venv,将其激活,但仍使用默认的python3.6
virtualenv --python=python3.5 testenv
Running virtualenv with interpreter /usr/bin/python3.5
Using base prefix '/usr'
New python executable in /home/mwon/testenv/bin/python3.5
Also creating executable in /home/mwon/testenv/bin/python
Installing setuptools, pip, wheel...done.
然后
source testenv/bin/activate
结果:
python
Python 3.6.5 (default, Mar 29 2018, 03:28:50)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
编辑:
发行版:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS"
NAME="Ubuntu"
VERSION="16.04.3 LTS (Xenial Xerus)"
Python版本:
Python 3.6.5