美文网首页Python
virtualenvwrapper 创建虚拟环境(指定版本的py

virtualenvwrapper 创建虚拟环境(指定版本的py

作者: 默芥子 | 来源:发表于2018-07-26 10:01 被阅读0次

使用 mkvirtualenv [venvname] 创建虚拟环境时,环境初始化的python版本拷贝来源于 /usr/bin/python

不过使用mkvirtualenv时 可以指定python版本,如:

mkvirtualenv --python=python3.5 venvname # venvname 虚拟环境名称
或
mkvirtualenv -p python3.5 venvname # venvname 虚拟环境名称

相关参数的详细解释:

-p PYTHON_EXE, --python=PYTHON_EXE
                        The Python interpreter to use, e.g.,
                        --python=python3.5 will use the python3.5 interpreter
                        to create the new environment.  The default is the
                        interpreter that virtualenv was installed with
                        (/usr/bin/python3)

当然,还有另外一种不太推荐的方式,全局环境下的python有多个版本共存时,也可创建软连接的方式改变默认的python版本链接;此后创建的虚拟环境默认python版本便是改变后的python版本。

end

相关文章

网友评论

    本文标题:virtualenvwrapper 创建虚拟环境(指定版本的py

    本文链接:https://www.haomeiwen.com/subject/fivvmftx.html