VIRTUALENV installation and use of a Python virtual environment under Windows

Source: Internet
Author: User
Tags windows x86 virtual environment virtualenv

This article describes the installation of Python's virtual environment virtualenv in the ubuntu16.04 environment, and the installation and use in the Windows environment.

Environmental information
    • Operating system: WINDOWS10

    • Python version: 3.6.3

Installation
    1. Download and install python3.6.3
    • Access official website: https://www.python.org/downloads (Windows)

    • Select: Windows x86-64 web-based Installer

Windows x86-64 web-based installer  # 指的是安装的时候需要联网,体积小,下载快,推荐Windows x86-64 executable installer  # 指的是使用XXX.exe文件的方式安装,下载体积大Windows x86-64 embeddable zip file  # 嵌入式版本
    1. Double click to start the installation, note tick on add Python to path, the other all the way to default;

    2. Test: Enter python at the command line to display the Python interface while the installation is successful;

Attention

    • If Python is not recognized, the most likely cause is that the add environment variable is not successful, go to the system environment variable to see it, do not add;
Installing Virtualenv
    • python3.6.3 version comes with Pip, in order to reduce the installation steps, using PIP installation;

    • CMD, open the Windows command line;

pip install virtualenvpip install virtualenvwrapper  
    • After the installation is complete, enter the PIP list to view all the currently installed packages;
Create a virtual environment
    • Select a file to hold the virtual environment, such as E:/python3
cd E:python3  # 进入该文件virtualenv envname   # 创建一个名字为envname的虚拟环境dir     # 查看当前目录可以知道一个envname的文件已经被创建
    • Start the virtual environment
# 进入虚拟环境文件cd envname# 进入相关的启动文件夹cd Scriptsactivate  # 启动虚拟环境deactivate # 退出虚拟环境

The following are free to install various packages in a virtual environment.

Questions and Details

    • Every time you need to start a virtual environment, you need to enter the virtual environment of the folder Scripy directory, very inconvenient, you can add scripy path to the system environment variables.

    • If the system also installs another Python version, such as python2.7.13, and adds its path to the system environment variable, go to the installation file directory, change the Python.exe file to Python2.exe file, and prevent the command from conflict;

    • If there are multiple versions of Python at the same time, there are multiple versions of PIP, which is required to specify the Python version when using PIP installation.

python -m pip install xxx   # python3版本安装包python2 -m pip install xxx  # python2版本安装包
    • Each time you add a system environment variable, you need to close the current CMD window and restart a window before it takes effect.

VIRTUALENV installation and use of a Python virtual environment under Windows

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.