标签:内容 cti 步骤 copyright name vat 执行 设置 bash
1.1 CentOS Linux release 7.7.1908 (Core)
[root@localhost ~]# find / -name python3 /root/envs/py3test/bin/python3 /root/envs/p3test/bin/python3 /usr/bin/python3 /home/admin/Envs/py3test/bin/python3
路径为:/usr/bin/python3
[root@localhost ~]# whereis virtualenvwrapper.sh virtualenvwrapper: /usr/local/bin/virtualenvwrapper.sh
yum install python-setuptools python-devel pip install virtualenvwrapper
[root@localhost ~]# vi .bashrc
添加如下内容:
WORKON_HOME=~/Envs VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 source=/usr/local/bin/virtualenvwrapper.sh
解释如下:
需要特别注意,CentOS中默认安装python2,如果这边不指定,创建虚拟环境时将提示/usr/bin/python: No module named virtualenvwrapper
source ~/.bashrc
[root@localhost ~]# mkvirtualenv -p /usr/bin/python p2test
[root@localhost ~]# mkvirtualenv p3test
[root@localhost ~]# workon
运行结果:
p2test p3test
[root@localhost ~]# workon p2test
(p2test) [root@localhost ~]# python
运行结果:
Python 2.7.5 (default, Aug 7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
(p2test) [root@localhost ~]# deactivate
[root@localhost ~]# rmvirtualenv py3test
centos7安装虚拟环境 virtualenvwrapper
标签:内容 cti 步骤 copyright name vat 执行 设置 bash
原文地址:https://www.cnblogs.com/hester/p/12369522.html