One minute - to create a virtual environment python

python to create a virtual environment

  python install third-party libraries are mostly installed by pip command, which is really very simple, but for each individual project, the need to use the library might be different if the original delete or update an existing repository, other projects might lead to error, this time, the virtual environment can play a role. Ha ha ~ ~ ~

  So, to create a virtual environment through the python, can be separated from development under different environmental projects.

 

  Xiao Bian materials used:

    Environment: python3.7 win10

    Tool: pthon own - >> venv

    Step: very simple ^ v ^, let us come together ......

 

  1. Open the cmd command window under the corresponding directory

      Tips: switching paths: cd path switching drive: drive:

    Method 1: WIN + R open the Run window, enter cmd, enter into the command window, through cd 'path' into the corresponding directory

 

 

    Method II [easy]: open the corresponding directory, the display input path cmd in the text box, enter into the command window

 

 

  2. Create a directory virtual environment

     Enter the following command in the above command window to do so, after creating the virtual environment will be under the directory.

md EnvTest

  3. Create a virtual environment

    Before creating the first into the directory just created.

cd EnvTest

    After entering directory, start creating a virtual environment, the following code, envTest is the name of the virtual environment, the same , since this can own name.

python -m venv envTest

  4. Activate environment

     Enter the following command in the current path to open the virtual environment.

envTest\Scripts\activate

    After a carriage return, displayed in the forefront (envTest)

    Now, you can do what you want to do the ......

  5. inactivation environment

    Similarly, as long as the current path, a command to turn off the virtual environment.

envTest\Scripts\deactivate

 

 

  Well, the virtual environment is that simple, of course, is to use a tool that comes with python, you can also use other third-party tools Oh!

 

Guess you like

Origin www.cnblogs.com/bpf-1024/p/11701560.html