[root@Asimov /Env_virtualenv]#pip install virtualenv ##在指定目录下安装
[root@Asimov /Env_virtualenv]#virtualenv ENV ##定义虚拟环境
New python executable in /Env_virtualenv/ENV/bin/python
Installing setuptools, pip, wheel...done.
[root@Asimov /Env_virtualenv/ENV/bin]#ls
activate activate_this.py pip python python-config
activate.csh easy_install pip2 python2 wheel
activate.fish easy_install-2.7 pip2.7 python2.7
[root@Asimov /Env_virtualenv/ENV/lib/python2.7/site-packages]#ls
easy_install.py pip-10.0.1.dist-info setuptools-39.1.0.dist-info
easy_install.pyc pkg_resources wheel
pip setuptools wheel-0.31.1.dist-info
##虚拟环境默认安装的库都在/Env_virtualenv/ENV/lib/python2.7/site-packages
[root@Asimov /Env_virtualenv]#virtualenv --no-site-packages ENV ##最新的virtualenv默认情况下,虚拟环境会依赖系统环境中的site packages,就是说系统中已经安装好的>第三方package也会安装在虚拟环境中
New python executable in /Env_virtualenv/ENV/bin/python
Installing setuptools, pip, wheel...done.
[root@Asimov /Env_virtualenv/ENV]#source ./bin/activate ##进入虚拟环境
(ENV) [root@Asimov /Env_virtualenv/ENV]#
(ENV) [root@Asimov /Env_virtualenv/ENV]#deactivate ##退出
[root@Asimov /Env_virtualenv/ENV]#
root@Asimov ~]#virtualenv -p /usr/local/python3/bin/python3.6 ENV3.6 ##指定使用的解释器
Running virtualenv with interpreter /usr/local/python3/bin/python3.6
Using base prefix '/usr/local/python3'
New python executable in /root/ENV3.6/bin/python3.6
Also creating executable in /root/ENV3.6/bin/python
Installing setuptools, pip, wheel...done.
PS:以后补充