There are a lot of choices these days for python virtual environments. This cheatsheet covers the basics of all of them so I can easily switch between when working with different teams. No favorites here!
- pipenv
- poetry
- venv
- conda
- virtualenv
Reference: Pipenv
Pipenv uses pip for dependency management and virtualenv for creating virtual environments.
Install:
pip install --user pipenvCreate env or activate:
pipenv shellDeactivate:
exitAdd dependencies:
# normal install
pipenv install langchain
# install specific version
pipenv install langchain==0.2.1
# install as dev dependency
pipenv install pytest --dev
# install all dependencies
pipenv install
# install all plus dev dependencies
pipenv install --devRemove dependencies:
# remove dependency
pipenv uninstall langchain
# remove all dev dependencies
pipenv uninstall --all-dev
# remove all dependencies
pipenv uninstall --allUpdate dependencies:
# update all dependencies
pipenv update
# update specific dependency
pipenv update langchainCreate lockfile (Pipfile.lock):
pipenv lockUse with requirements.txt:
pipenv lock --requirements > requirements.txtpipenv install --requirements requirements.txtLocate the virtual environment:
pipenv --venvDelete the virtual environment:
pipenv --rmReference: Poetry
Install:
curl -sSL https://install.python-poetry.org | python3 -Create env or activate:
poetry shellUsage:
# add dependency
poetry add langchain
# install specific dependency
poetry install langchain==0.2.1
# add dev dependency
poetry add pytest --dev
# install all dependencies
poetry install
# install all plus dev dependencies
poetry install --devLocate the virtual environment:
poetry env infoDelete the virtual environment:
poetry env removeReference: venv
Create env or activate:
python -m venv myenv
source myenv/bin/activateUsage:
pip install langchain
...Reference: conda
Create env or activate:
conda create -n myenvUsage:
conda install langchainReference: virtualenv
Create env or activate:
python -m venv myenv
source myenv/bin/activateUsage:
pip install langchain
...