首先默认安装了virtualenv 创建python3虚拟环境
your-name@node-name:~/virtual_env$ virtualenv -p /usr/bin/python3 py3env接着会输出
Already using interpreter /usr/bin/python3 Using base prefix '/usr' New python executable in /home/your_name/virtual_env/py3env/bin/python3 Also creating executable in /home/your_name/virtual_env/py3env/bin/python Installing setuptools, pkg_resources, pip, wheel...done.这时候就创建出了一个python3的环境,然后测试下是否是我们想要的环境 激活环境
source ~/virtual_env/py3env/bin/activate然后 shell 终端会有这样的前缀
(py3env) your-name@node-name:~/virtual_env$这表明你已经进入了这个python3的虚拟环境 然后查看是否是python3
(py3env) your-name@node-name:~/virtual_env$ python输出
Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>>可以看出python环境是3.5.2 下面介绍退出虚拟环境 在shell终端输入
(py3env) your-name@node-name:~/virtual_env$ deactivate然后终端显示
your-name@node-name:~/virtual_env$转载于:https://www.cnblogs.com/vercont/p/10210229.html
相关资源:JAVA上百实例源码以及开源项目