Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Markdown
### Creating a Virtual Python Environment
```console
# Python 3
$ python3 -m venv env_name
```
And that's just it. It is important to use the __venv__ module as others are deprecated. The name of the environment can be anything as it is just a directory name, however it is good practice to use names like __*env*__ or __*venv*__ or expand with these names.


#### Create a Virtual Environment With System Site Package Inheritance
For packages developed on a clustered system such as GateWay, it may be necessary to inherit packages from the system site environment typically set with modules. To achieve this, add the __--system-site-packages__ option when creating a new virtual environment.
```console
$ python -m venv env_name --system-site-packages
```

### Activate The Virtual Environment
To activate the environment just created, navigate to the location where it was created, if not already there, and execute the following command:
```console
$ source env_name/bin/activate
(env_name): $
```
As a result of activation, the currently used shell should explicitly show the name of the environment being activated on the command line.

### Deactivate The Virtual Environment
After finishing work with the environment, it can be deactivated in the following way:
```console
(env_name): $ deactivate
```


Info
titleRemoving The Virtual Environment

Normally it is not necessary to remove the environment, but this can be achieved by simply deleting the env_name directory.


Markdown
### Upgrade PIP Inside The Virtual Environment
It is always good practice to update the PIP, even if it is up-to-date on the system site. This time the user should be able to access all files in the project directory, so there is no need to use the local __--user__ flag with the __*install*__ command.
On GateWay, it should look like this:
```console
# Python 3
$ python -m venv env_name --system-site-packages
$ source env_name/bin/activate
(env_name): $ python3 -m pip install --upgrade pip
```