About python started writing project to create a virtual environment

About python started writing project to create a virtual environment

What is a virtual environment?

  • Sometimes we find that there are multiple items on a computer, a dependent Django 2.1, another older projects have to use the Django 1.5, this time how to do it?
  • We need to rely on a package management tools to handle the development of more non-interfering environment.
  • virtualenv will be able to solve such a problem, it creates a separate environment, the library will be installed under its own directory, and other environments will not share.

virtualenv和virtualenvwrapper

  •   Since virtualenv with little trouble, it was the package wrapper to make it easier to use, we use the command wrapper eventually provided, but the actual work is done virtualenv.
  • Virtualenvwrapper advantage is that the overall virtual environment to manage, do not build for each project. The same type of project can create the same virtual environment, where they do not ignore it, you can direct a workon.

Virtualenvwrapper operation

 

1. Create a virtual environment: mkvirtualenv virtual environment name

2. Switch to a virtual environment: workon my_envde

3. Exit current virtual environment: deactivate

4. Delete a virtual environment: rmvirtualenv my_env

5 lists all the virtual environment: lsvirtualenv

 

Command line appears (---) represents the use of the virtual environment

Install django, pymysql in a virtual environment

Execution activate in cmd

Into the virtual environment pip freeze confirmation virtual environments pip is completed

 

installation

  • pip upgrade
  • python -m pip install --upgrade pip
  • Virtualenv installation
  • pip install  virtualenv
  • virtualenvwrapper installation
  • pip install virtualenvwrapper-win
  • Set Environment Variables WORK_HOME
  • The default path: C: \ Users \ admin \ Envs
  • WORKON_HOME = D:\test\vritualenv

 

Guess you like

Origin www.cnblogs.com/pythonyeyu/p/11318896.html