虚拟的python环境,能在本地目录安装不同版本的python环境,在开发新应用时可以创建虚拟环境,保持我们的系统模块干净
1,安装pip3
sudo pip3 install virtualenv
2,使用
root@ubuntu:/home/z# pip install virtualenv 安装virtualenv
Collecting virtualenv
Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB)
100% |████████████████████████████████| 1.8MB 35kB/s
Installing collected packages: virtualenv
Successfully installed virtualenv-15.1.0
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
root@ubuntu:/home/z# mkdir virtual 创建虚拟目录
root@ubuntu:/home/z# cd virtual/
root@ubuntu:/home/z/virtual# virtualenv virt1 创建一个名为virt1的环境
New python executable in /home/z/virtual/virt1/bin/python
Installing setuptools, pip, wheel...done.
root@ubuntu:/home/z/virtual# source virt1/bin/activate 激活
(virt1) root@ubuntu:/home/z/virtual# deactivate 关闭虚拟环境
root@ubuntu:/home/z/virtual#