Advertisement
Jackspade9624

virtual environment

Feb 28th, 2025 (edited)
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. python3 -m venv venv source venv/bin/activate
  2.  
  3.  
  4. venv is a module in Python used for creating virtual environments. A virtual environment is an isolated space where Python projects can have their own dependencies, preventing conflicts between different projects. It allows you to manage packages for specific projects without affecting the global Python installation or other projects.
  5. To create a virtual environment, you can use the following command in your terminal:
  6. Code
  7.  
  8.  
  9. python -m venv <environment_name>
  10.  
  11.  
  12. Replace <environment_name> with the desired name for your virtual environment (e.g., .venv, myenv). This command creates a directory containing the necessary files for the virtual environment.
  13. To activate the virtual environment, use one of the following commands, depending on your operating system: On Windows.
  14. Code
  15.  
  16.  
  17. <environment_name>\Scripts\activate
  18.  
  19.  
  20. On macOS and Linux.
  21. Code
  22.  
  23.  
  24. source <environment_name>/bin/activate
  25.  
  26.  
  27. Once activated, the environment name will appear in parentheses or brackets at the beginning of your terminal prompt, indicating that you are working within the virtual environment.
  28. To deactivate the virtual environment, simply type deactivate in the terminal.
  29. Code
  30.  
  31.  
  32. deactivate
  33.  
  34.  
  35. When the virtual environment is deactivated, you will revert back to the global Python environment.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement