ob-vaults/Phoenix/Python/virtual environment python.md
2024-09-12 17:54:01 +03:30

75 lines
1.8 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

status: #doc #unfinished
Tags: #python #env #programming
links:[[python]]
Date: 2023-04-26
___
# virtual environment python
## [venv](https://docs.python.org/3/library/venv.html)
### making new env
* for making new virtual env use this command
```bash
python -m venv /path/to/new/virtual/environment
```
### activating env
* activating env in bash/zsh
```bash
source <venv>/bin/activate
```
* activating in fish
```bash
source <venv>/bin/activate.fish
```
* activating in windows
```powershell
PS C:\> <venv>\Scripts\Activate.ps1
```
### deactivating env
* deactivating in all systems
```bash
(.venv)$ deactivate
```
## [Virtualenv](https://virtualenv.pypa.io/en/latest/)
`virtualenv` is a tool to create isolated Python environments , The `venv` module does not offer all features of this library, venv is slower,not as extendable,- is not upgrade-able via [pip](https://pip.pypa.io/en/stable/installation/),- does not have as rich programmatic API (describe virtual environments without creating them).
### [Installation](https://virtualenv.pypa.io/en/latest/installation.html)
#### via pipx
```bash
pipx install virtualenv
virtualenv --help
```
other ways are not as good but if needed are in documentation
#### via [zipapp](https://docs.python.org/3/library/zipapp.html)
You can use Virtualenv without installing it too. pypa publish a Python [zipapp](https://docs.python.org/3/library/zipapp.html), you can just download this from [this link](https://bootstrap.pypa.io/virtualenv.pyz) and invoke this package with a python interpreter:
``` bash
python virtualenv.pyz --help
```
## [Poetry](https://python-poetry.org/docs/)
---
# References
https://dev.to/bowmanjd/python-tools-for-managing-virtual-environments-3bko#poetry
https://dev.to/bowmanjd/getting-started-with-python-poetry-3ica