Python Quarantine Sandbox Virtualenv

Source: Internet
Author: User
Tags virtual environment virtualenv

I think a big advantage of Python is that the numerous software packages available on the official website will almost help you achieve whatever functionality you want and avoid repetitive development work, but fragmented packages and various versioning of each package become a tricky issue. So with the advent of virtuallenv, after installing this, it is equivalent to having a separate memory space, for example, you have a project called Mysite_1, using the Python2.7 version, another project is Mysite_ 2, using the Python3.0 version, due to the Python version of each other compatibility differences, the general method is through the configuration file, let the project Mysite_1 read Python2.7 directory, mysite_2 read Python3.0 directory. A simpler approach now is to isolate the individual projects by isolating the sandbox as a virtual environment.

The installation and use of virtualenv under the Windows platform is described below.

(1) Official website download https://virtualenv.pypa.io/en/latest/

I usually use pypm to download:

----------------------------------------------------------------

PYPM Install Virtualenv-g

----------------------------------------------------------------

-G means to install in Python's default global directory, usually under the Site-packages directory of LIB, we can also make virtualenv installation directory, through-e DIR or--virtualenv = dir to set up, However, it is recommended to install virtualenv under the Site-packages directory.

(for example, pypm-e C:\mysite_1 install-r config\requirements.pip means that all files under the requirement directory are downloaded and installed into the Mysite_1 directory under the C drive)

(2) Create a virtual directory

----------------------------------------------------------------

Go to the directory you want to create, such as C drive

CD C + +

Virtualenv Mysite_1

----------------------------------------------------------------

At this point, under the C drive, you can find the newly generated Mysite_1 folder, which contains three files, respectively

Mysite_1--------*include

--------*lib

--------*scripts

(3) Start

Open the Scripts folder under Mysite_1,

>CD Mysite_1

C:\mysite_1

>CD Script

C:\mysite_1\script>activate

(mysite_1)C:\mysite_1\Script

Find a name for the project directory you created earlier, indicating that you have entered the virtual environment at this point.

We can install with the PYPM installation tool, or we can install it using the PIP tool, but Pip is recommended. The reason is that PIP has a more powerful function.

(a) method of installation using PYPM

Pypm-e C:\mysite_1 Install-r Config\requirement.pip

(b) Using the PIP installation method

Pip Install-r Config\requirement.pip

It is important to note that for (a), we specify an absolute path to the installation, so it can be installed without going into the quarantine sandbox, but for (b) We must use it in case of ingress into the quarantine sandbox.

In addition, under window we can also download the files from the. Pip, unzip the Python setup.py install, and use it in the case of a quarantine sandbox.

Detailed instructions on how to use Pip and pypm can be found in the detailed documentation.

(4) Exit

You just need to execute deactivate to exit the virtual environment.

We're downloading a project from Djangopackages. Experimenting with the use of virtual directories

Http://mysmile.readthedocs.org/en/latest/Getting%20started/quick_install_guide.html

(1)

[note] The --system-site-packages Option

If you build with virtualenv --system-site-packages ENV, your virtual environment would inherit Packages from /usr/lib/python2.7/site-packages (or wherever your global site-packages directory is).

This can is used if you had control over the global site-packages directory, and you want to depend on the packages there . If you want isolation from the global system, don't use the this flag.

Unzip the downloaded Mysmile file into the virtual sandbox, with the following file structure:

Mysite_1--------*include

--------*lib

--------*scripts

--------*mysmile-0.5.1

Enter the mysmile-0.5.1. You can see the manage.py file, start: Python manage.py runserver. Enter http://127.0.0.1:8000/admin in the URL to see the Web page launched below:

Mysmile Administration

Reference:

Http://mengzhuo.org/blog/virtualenv%E5%92%8Cpip%E5%B0%8F%E6%8E%A2.html

Python Quarantine Sandbox Virtualenv

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.