Python TutorialLesson 36Free preview
Python VirtualEnv
This lesson is part of Python · All levels
Summary
A virtual environment is an isolated folder containing a copy of a Python interpreter and a project-specific library. With the python -m venv name command, each project has its own dependencies so that the library versions between the projects do not clash. Once created, the environment must be activated before use and deactivated again with the deactivate command.
Key points
- Create a virtual environment with python -m venv name_env.
- Activate in Windows: name_env\Scripts\activate; in macOS/Linux: source name_env/bin/activate.
- When the environment is active, pip installs only installs the library into the env folder, not the global one.
- Add the env folder to the repository to avoid being committed. (.gitignore)
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.