一、安装自己需要的python版本
步骤略
二、安装virtualenv模块并创建虚拟环境
[root@localhost ~]# /usr/local/python3.6.8/bin/pip3 install virtualenv [root@localhost ~]# /usr/local/python3.6.8/bin/virtualenv --version [root@localhost ~]# mkdir py_virtual [root@localhost ~]# cd py_virtual [root@localhost py_virtual]# /usr/local/python3.6.8/bin/virtualenv test [root@localhost py_virtual]# ll 总用量 0 drwxr-xr-x. 4 root root 64 9月 26 09:55 test [root@localhost py_virtual]# cd test1/ [root@localhost py_virtual]# source bin/activate #激活虚拟环境 (test) [root@localhost py_virtual]# python -V Python 3.6.8 (test) [root@localhost ~]# deactivate #退出虚拟环境
三、指定其他python版本创建
[root@localhost py_virtual]# /usr/local/python3.6.8/bin/virtualenv --python /usr/local/python3.5.7/bin/python3 test1 [root@localhost py_virtual]# ll 总用量 0 drwxr-xr-x. 4 root root 64 9月 26 09:55 test drwxr-xr-x. 4 root root 64 9月 26 10:09 test1 [root@localhost py_virtual]# cd test1/ [root@localhost test1]# source bin/activate (test1) [root@localhost test1]# python -V Python 3.5.7
标签:test1,virtualenv,Python,py,virtual,Centos7,虚拟环境,root,localhost From: https://www.cnblogs.com/panwenbin-logs/p/16729991.html