Virtual Environments ensure that dependencies from one Python application don’t overwrite the dependencies of another application. In this lesson, you will learn how to create a virtual environment, switch between virtual environments, and manage dependencies within a virtual environment.
Install:
pip install virtualenv
Create floder for a project:
mkdir my_project cd my_project
Use virtual env to generate python env:
virtualenv py3 -p /usr/local/bin/python3
Tell to use python3. Then it will create py3 folder.
To activate the env:
source py3/bin/activate
To deactivate
deactivate
To share the dependiences:
pip freeze > requirements.txt pip install -r requirements.txt
So other developers can use the same dependiences
时间: 2024-10-04 16:48:53