ob-vaults/Super_Vault/200_programming/python/virtual environment python.md
2024-09-12 17:54:01 +03:30

80 lines
1.9 KiB
Markdown
Raw Permalink 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 in current folder
```bash
python -m venv env
```
- env is name and address of virtual environment
ex: inside folder named foo environment of bar
```shell
python -m venv foo/bar
```
### activating env
* activating env in bash/zsh
```bash
source env/bin/activate
```
* activating in fish
```bash
source env/bin/activate.fish
```
* activating in windows
```powershell
PS C:\> env\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