4: Virtual Environments(Command line Python scripting )
来源:互联网 发布:瑞士 知乎 编辑:程序博客网 时间:2024/06/05 15:18
In the previous screen, we used the default version of pip, which installed requests
for thepython
executable, which is Python version 2.
What if we had instead wanted to installrequests
for Python 3? This type of version switching can get confusing, and different projects can require different packages and Python versions. A nice way to avoid issues with different package versions are virtual environments. By default, the system has onepython
executable, and you have to install all packages and libraries globally. This means that every single project on your machine has to use the same version of Python, and the same versions of every package.
By default, you can't use different versions of Python without some hacks. One such hack is renaming python
to python3
so we can have access to both Python 2
and Python 3
.
A better solution for this is for each project we write to have its own version of Python, along with its own packages. This way, we don't need to worry that upgrading the version of a package will affect other projects on the system and cause them to stop working.
Virtual environments, or virtualenvs, let us do this. You can create a new virtualenv with thevirtualenv
command. In order to access this, you normally have to install the virtualenv package, but we've already installed it to simplify the process.
Typing virtualenv main
will create a virtualenv named main
. It will create a folder in the current directory called main
that will hold all the packages you install into the virtual environment.
Instructions
Type virtualenv python2
in the /home/dq
directory to create a new virtual environmented named python2
.
- Note how it makes a folder called
python2
.
- 4: Virtual Environments(Command line Python scripting )
- 2: Python Versions(Command line Python scripting)
- 1: Command Line Python(Command line Python scripting)
- 9: Command Line Arguments(Command line Python scripting)
- 3: Installing Packages(Command line Python scripting )
- Python Virtual Environments 原理
- 5: Python 3 Virtualenv(Command line Python scripting )
- 6: Activating A Virtualenv( Command line Python scripting )
- 7: Checking The Installed Packages(Command line Python scripting)
- 8: Importing A File(Command line Python scripting)
- 10: Deactivating A Virtualenv(Command line Python scripting )
- Linux Command Line and Shell Scripting Bible
- Python3.4 虚拟环境配置 virtual environments
- 《Linux Command Line and Shell Scripting》编译序曲
- Linux Command Line and Shell Scripting Bible,3rd,PartI
- [译]The Python Tutorial#12. Virtual Environments and Packages
- 1: Command Line Python(Challenge: Working with the Command Line)
- Wiley.Linux.Command.Line.and.Shell.Scripting.Bible.May.2008.eBook-BBL
- android studio编码格式编译运行异常:Error:(1, 1) 错误: 非法字符: '\ufeff';
- 2: Python Versions(Command line Python scripting)
- ubuntu 国内源
- 在Qt 5.7 下配置OpenCV 开发环境
- 3: Installing Packages(Command line Python scripting )
- 4: Virtual Environments(Command line Python scripting )
- public, private, protected访问修饰符
- Leetcode 58 之反向迭代器的使用
- 5: Python 3 Virtualenv(Command line Python scripting )
- muduo网络库源码分析-定时器
- 6: Activating A Virtualenv( Command line Python scripting )
- 转:实用工具软件分享
- Cocos2d 游戏帧循环的理解和定时器的使用
- EJB框架的基本原理