How to install and use virualenv in python virtual environment

Source: Internet
Author: User
Tags virtualenv
Preface after installing python, pip, setuptools, and other tools, you can create a virualenv virtual environment, which is similar to a virtual machine tool, it is a good development tool that allows the same brain to run multiple python programs of different versions without affecting each other. you can exit or delete them when you don't need them. 1. install virtualenv # installpiponmacbrewinstallpythoncurlhttps Preface
After installing python, pip, setuptools, and other tools, you can create a virualenv virtual environment. This tool is similar to a virtual machine and allows the same brain to run multiple python programs of different versions, don't affect each other. you can exit or delete it when you don't need it. it's a good development tool.
1. install virtualenv

#install pip on macbrew install pythoncurl https://bootstrap.pypa.io/ez_setup.py -o - | sudo pythonsudo easy_install pip#install virtualenv by pippip install virtualenv


II. Use of virtualenv

# Create a new environment called pythonEnv virtualenv pythonEnv # activate and then use cd pythonEnvsource bin/activate # exit the environment deactivate


III. use virtualenvwrapper to manage virtual environments
Install virtualenvwrapper

pip install virtualenvwrapper


Configure environment variables:

vim ~/.bash_profile# Virtualenv/VirtualenvWrappersource /usr/local/bin/virtualenvwrapper.sh# exit vimsource ~/.bash_profile


Create environment

Mkvirtualenv pythonEnv # In ~ /Envs create the pythonEnv folder mkvirtualenv python3Env-p python3.5 # create the python3.5 environment


Switch environment:

workon pythonEnv


Exit environment:

deactivate


Delete environment:

rmvirtualenv pythonEnv


Others
1. other commands

Lsvirtualenv # List all environments. Cdvirtualenv # navigate to the Directory of the activated virtual environment. for example, you can browse its site-packages. Cdsitepackages # is similar to the above, but directly enters the site-packages directory. Lssitepackages # displays the content in the site-packages directory.

2. the ImportError: No module named extern error occurs when pip is installed using the easy_install command.
Cause: The extern module of python2.7.12 in mac is not installed.
Solution:

#download from https://pypi.python.org/pypi/extern/0.1.0 tar zxf extern-0.1.0.tar.gz && python setup.py install

The above describes how to install and use virualenv in the python virtual environment. For more information, see other related articles in the first PHP community!

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.