Starting Python 3.6 - virtual environment creation module shipped as part of Python installation.
Here is example - how to create virtual environment using Python 3.6
python -m venv env
This command creates new forlder "env" in current directory (if directory not yet exists). It also create subdirectories in "env" directory that containing a copy of the Python interpreter, the standard library, supporting files, etc.
After virtual environment is created- it needs to be activated:
Depend on OS type- it can be done in several ways.
For Windows:
.\env\Scripts\activate.bat
For Linux:
./env/Scripts/activate.sh
After virtual environment is activated- shell will show activated virtual environment as a prefix in command prompt: (venv).
Now we can install all the required libraries for our current Python application.
For example:
python -m pip install beautifulsoup4
python -m pip install lxml
All the installed packages will be stored inside of "venv" folder and not overlap/affect any other Python applications.
v
No comments:
Post a Comment