Skip to content

Instantly share code, notes, and snippets.

@ziritrion
Last active May 13, 2025 21:53
Show Gist options
  • Save ziritrion/8024025672ea92b8bdeb320d6015aa0d to your computer and use it in GitHub Desktop.
Save ziritrion/8024025672ea92b8bdeb320d6015aa0d to your computer and use it in GitHub Desktop.

Revisions

  1. ziritrion revised this gist Oct 1, 2024. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -49,6 +49,8 @@ For when you want to create an environment on an already existing project folder
    * `uv add package`
    1. Remove a package (with the venv activated)
    * `uv remove package`
    1. If your requirements.txt (or pyproject.toml) file has changed, sync the environment to make sure that all packages match:
    * `uv pip sync requirements.txt`
    1. Run code without activating the venv
    * `uv run python my_app.py`
    1. Export dependencies to `requirements.txt`
  2. ziritrion revised this gist Sep 30, 2024. 1 changed file with 37 additions and 0 deletions.
    37 changes: 37 additions & 0 deletions pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -30,6 +30,43 @@ A project is a folder with some preconfigured files for ease of use, the most im
    * You need to execute this from the project's folder.
    * If no environment is present, `uv` will automatically create it.

    ### Creating and managing environments

    For when you want to create an environment on an already existing project folder.

    1. Create an environment
    * `uv venv` > creates an environment at `.venv`.
    * `uv venv name` > creates an environment at `name`.
    * `uv venv --python 3.11` > creates an environment with the specified Python version.
    1. Activate the environment
    * `source .venv/bin/activate` > you may change `.venv` to whatever folder you used for your venv.
    1. Deactivate the environment
    * `deactivate`
    1. Install packages from your requirements file (with the venv activated)
    * `uv pip install -r requirements.txt`
    * `uv pip install -r pyproject.toml`
    1. Add a single package to the venv (with the venv activated)
    * `uv add package`
    1. Remove a package (with the venv activated)
    * `uv remove package`
    1. Run code without activating the venv
    * `uv run python my_app.py`
    1. Export dependencies to `requirements.txt`
    * `uv export --format requirements-txt`
    * Note that the exported file will be a lockfile with pinned versions.
    * The actual lockfile used by `uv` is `uv.lock`. Both `pyproject.toml` and `uv.lock` are more modern solutions that `requirements.txt`.

    ### Cleanup

    1. Remove an environment
    * Simply remove the .venv folder.
    1. Clean the cache
    * `uv cache clean`
    * This will delete the entire cache!
    1. Clean the cache of unused entries.
    * `uv cache prune`
    * Much safer than the previous command.

    # Conda

    Manages packages and virtual environments for you. Good for Data Science but it sucks for dockerizing.
  3. ziritrion revised this gist Sep 29, 2024. 1 changed file with 19 additions and 19 deletions.
    38 changes: 19 additions & 19 deletions pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -9,26 +9,26 @@ Experimental but very promising `pip` replacement that handles package managing
    Note that you don't have to actively install a Python version! `uv` will automatically fetch the required Python version for your project.

    1. Install a Python version (or many)
    * `uv python install 3.11 3.12`
    * `uv python install 3.11 3.12`
    1. View your installed Python versions
    * `uv python list`
    * `uv python list`

    ### Creating and managing projects

    A project is a folder with some preconfigured files for ease of use, the most important being `pyproject.toml`, which defines the project's dependencies.

    1. Create a project
    * `uv init my_project`
    * This will create a `my_project` folder in the current directory with the following files:
    * `.python-version`
    * `README.md`
    * `hello.py`
    * `pyproject.toml`
    * The project folder will NOT contain a virtual environment by default.
    * `uv init my_project`
    * This will create a `my_project` folder in the current directory with the following files:
    * `.python-version`
    * `README.md`
    * `hello.py`
    * `pyproject.toml`
    * The project folder will NOT contain a virtual environment by default.
    1. Add packages
    * `uv add package`
    * You need to execute this from the project's folder.
    * If no environment is present, `uv` will automatically create it.
    * `uv add package`
    * You need to execute this from the project's folder.
    * If no environment is present, `uv` will automatically create it.

    # Conda

    @@ -96,16 +96,16 @@ Keep in mind that virtual environments created with `venv` are not activated aut
    ### Creating and managing

    1. Create a virtual environment.
    * `python -m venv path/to/virtual/environment/folder`
    * By convention, the usual virtual environment folder is called `.venv` and placed in the root folder of your project. In these notes, it is assumed that all paths begin from the project's root folder and that `.venv` is the chosen name for the virtual environment.
    * The Python version of the venv will be the same you're using at the moment. I recommend using [pyenv](https://github.com/pyenv/pyenv) for managing your Python versions; you can activate a local Python version on the project folder and generate the venv afterwards.
    * `python -m venv path/to/virtual/environment/folder`
    * By convention, the usual virtual environment folder is called `.venv` and placed in the root folder of your project. In these notes, it is assumed that all paths begin from the project's root folder and that `.venv` is the chosen name for the virtual environment.
    * The Python version of the venv will be the same you're using at the moment. I recommend using [pyenv](https://github.com/pyenv/pyenv) for managing your Python versions; you can activate a local Python version on the project folder and generate the venv afterwards.
    1. Activate the virtual environment.
    * `source .venv/bin/activate`
    * `source .venv/bin/activate`
    1. Install dependencies from a requirements.txt file (you need to be on an activated venv).
    * `pip install -r requirements.txt`
    * You can use any other `pip` commands, such as `pip install package_name` and `pip list` to see installed packages.
    * `pip install -r requirements.txt`
    * You can use any other `pip` commands, such as `pip install package_name` and `pip list` to see installed packages.
    1. Deactivate environment.
    * `deactivate`
    * `deactivate`

    ### Cleanup

  4. ziritrion revised this gist Sep 29, 2024. 1 changed file with 32 additions and 0 deletions.
    32 changes: 32 additions & 0 deletions pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,35 @@
    # uv

    Experimental but very promising `pip` replacement that handles package managing as well as virtual environments and Python version management.

    `uv` comes included with `uvx`, an alias for `uv tool run`. `uvx` allos you to install and execute command-line tools on an ephemeral environment.

    ### Python versions

    Note that you don't have to actively install a Python version! `uv` will automatically fetch the required Python version for your project.

    1. Install a Python version (or many)
    * `uv python install 3.11 3.12`
    1. View your installed Python versions
    * `uv python list`

    ### Creating and managing projects

    A project is a folder with some preconfigured files for ease of use, the most important being `pyproject.toml`, which defines the project's dependencies.

    1. Create a project
    * `uv init my_project`
    * This will create a `my_project` folder in the current directory with the following files:
    * `.python-version`
    * `README.md`
    * `hello.py`
    * `pyproject.toml`
    * The project folder will NOT contain a virtual environment by default.
    1. Add packages
    * `uv add package`
    * You need to execute this from the project's folder.
    * If no environment is present, `uv` will automatically create it.

    # Conda

    Manages packages and virtual environments for you. Good for Data Science but it sucks for dockerizing.
  5. ziritrion revised this gist Sep 29, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -86,7 +86,7 @@ Keep in mind that virtual environments created with `venv` are not activated aut

    `pipenv` is a Python virtualenv management tools. `pipenv` does not have built-in package search; make sure you search for the packages at [PyPI](https://pypi.org/).

    Be aware that `pipenv` has some issues (very slow dependency lock, non-standard config file format) and that there are newer tools that may supplant it, such as [PDM](https://pdm-project.org/en/latest/)
    Be aware that `pipenv` has some issues (very slow dependency lock, non-standard config file format) and that there are newer tools that may supplant it, such as [PDM](https://pdm-project.org/en/latest/) or [uv](https://docs.astral.sh/uv/).

    ### Installation

  6. ziritrion revised this gist Sep 29, 2024. 1 changed file with 28 additions and 1 deletion.
    29 changes: 28 additions & 1 deletion pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -51,16 +51,43 @@ Manages packages and virtual environments for you. Good for Data Science but it
    1. Clean up the cache to remove packages and stuff
    * `conda clean --all`

    ### Replacing Conda with something better
    # Replacing Conda with something better

    Take a look at [Pixi](https://pixi.sh/latest/) as a drop-in replacement for Conda.

    # venv

    `venv` is included with Python. It's clunkier than some other tools but it's available mostly everywhere. It allows you to create virtual environments tied to a specific project because they are contained within a subfolder inside your project's folder.

    Keep in mind that virtual environments created with `venv` are not activated automatically.

    ### Creating and managing

    1. Create a virtual environment.
    * `python -m venv path/to/virtual/environment/folder`
    * By convention, the usual virtual environment folder is called `.venv` and placed in the root folder of your project. In these notes, it is assumed that all paths begin from the project's root folder and that `.venv` is the chosen name for the virtual environment.
    * The Python version of the venv will be the same you're using at the moment. I recommend using [pyenv](https://github.com/pyenv/pyenv) for managing your Python versions; you can activate a local Python version on the project folder and generate the venv afterwards.
    1. Activate the virtual environment.
    * `source .venv/bin/activate`
    1. Install dependencies from a requirements.txt file (you need to be on an activated venv).
    * `pip install -r requirements.txt`
    * You can use any other `pip` commands, such as `pip install package_name` and `pip list` to see installed packages.
    1. Deactivate environment.
    * `deactivate`

    ### Cleanup

    1. Delete the venv folder to get rid of it.
    * `rm -rf .venv`

    # Pipenv + Pyenv

    `pyenv` is a Python version manager. It allows you to install and manage multiple Python versions.

    `pipenv` is a Python virtualenv management tools. `pipenv` does not have built-in package search; make sure you search for the packages at [PyPI](https://pypi.org/).

    Be aware that `pipenv` has some issues (very slow dependency lock, non-standard config file format) and that there are newer tools that may supplant it, such as [PDM](https://pdm-project.org/en/latest/)

    ### Installation

    1. `pyenv`
  7. ziritrion revised this gist Sep 29, 2024. No changes.
  8. ziritrion revised this gist Sep 29, 2024. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    # Conda

    Manages packages and virtual environments for you. Good for Data Science but it sucks for dockerizing.

    ### Creating and managing

    1. Create a virtual environment
    @@ -49,6 +51,10 @@
    1. Clean up the cache to remove packages and stuff
    * `conda clean --all`

    ### Replacing Conda with something better

    Take a look at [Pixi](https://pixi.sh/latest/) as a drop-in replacement for Conda.

    # Pipenv + Pyenv

    `pyenv` is a Python version manager. It allows you to install and manage multiple Python versions.
  9. ziritrion revised this gist Jul 15, 2024. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -71,11 +71,15 @@

    The environments are based on the folder you're on. There is no need to manually name them, and there is no environment activation to take care of per se.

    1. Install the Python version you need
    1. (Optional) Install the Python version you need
    * `pyenv install 3.11`
    1. Create a new virtual environment with pipenv and choose the Python vrsion you want.
    * `pipenv install --python 3.11`
    3. Install a package (this will modify `Pipfile` and `Pipfile.lock`)
    * pipenv should automatically use pyenv to install the specified version if it is not found on your system.
    * If a `requirements.txt` file is present, it will be used to install your packages. If a `Pipfile` is present, it will be used instead of `requirements.txt` because it has priority.
    1. If you have a `requirements.txt` and a `Pipfile` and want to prioritize `requirements.txt`, you can choose which file to use in order to install packages:
    * `pipenv install -r requirements.txt`
    3. Install a single package (this will modify `Pipfile` and `Pipfile.lock`, but WILL NOT modify `requirements.txt` if it exists):
    * `pipenv install some_package`
    * `pipenv install some_package=1.0`
    4. If a `Pipfile.lock` file already exists, you can install the packages from it.
  10. ziritrion revised this gist Jul 8, 2024. 1 changed file with 23 additions and 0 deletions.
    23 changes: 23 additions & 0 deletions pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    # Conda

    ### Creating and managing

    1. Create a virtual environment
    * `conda create --name my_env_name python=3.8` or whatever Python version you may need.
    2. List available envs (2 different ways
    @@ -38,6 +40,15 @@
    17. If you don't want the base environment to load automatically whenever you open a new shell, change the configs:
    * `conda config --set auto_activate_base false`

    ### Cleanup

    1. List all available environments
    * `conda env list`
    1. Remove a specific environment
    * `conda env remove --name environment_name_to_be_deleted`
    1. Clean up the cache to remove packages and stuff
    * `conda clean --all`

    # Pipenv + Pyenv

    `pyenv` is a Python version manager. It allows you to install and manage multiple Python versions.
    @@ -79,6 +90,18 @@ The environments are based on the folder you're on. There is no need to manually
    8. Install all dependencies to the system, avoiding virtualenvs entirely (useful for deployment in containers)
    * `pipenv install --system --deploy` > Use this in your Dockerfile.

    ### Cleanup

    Pipenv environments are usually in `~/.local/share/virtualenvs/`; inspect the directory to see all the virtualenvs.

    To remove a virtualenv, navigate to its project directory and run:

    `pipenv --rm`

    After deleting the environment/s, you may want to clean up the pip cache:

    `pip cache purge`

    # Installing pipenv on Docker Dev Environment

    * Update apt
  11. ziritrion revised this gist Jun 17, 2024. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -50,6 +50,8 @@
    * https://github.com/pyenv/pyenv
    * `pyenv` can be installed with either Brew or with the automatic installer script.
    * For Windows, there is `pyenv-win` but I have not tested it.
    * For Ubuntu 22.04 LTS, make sure you run the following before installing:
    * `sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm xz-utils tk-dev libffi-dev liblzma-dev python3-openssl`
    1. `pipenv`
    * https://pipenv.pypa.io/en/latest/index.html
    * Install locally for your user with `pip install pipenv --user`
  12. ziritrion revised this gist May 21, 2024. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -35,6 +35,8 @@
    * `conda env export --from-history > environment.yml`
    16. Create a new environment and install dependencies listed in YML file.
    * `conda env create -f environment.yml`
    17. If you don't want the base environment to load automatically whenever you open a new shell, change the configs:
    * `conda config --set auto_activate_base false`

    # Pipenv + Pyenv

  13. ziritrion revised this gist Apr 10, 2024. 1 changed file with 8 additions and 6 deletions.
    14 changes: 8 additions & 6 deletions pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -58,19 +58,21 @@ The environments are based on the folder you're on. There is no need to manually

    1. Install the Python version you need
    * `pyenv install 3.11`
    1. Install a package (this will modify `Pipfile` and `Pipfile.lock`)
    1. Create a new virtual environment with pipenv and choose the Python vrsion you want.
    * `pipenv install --python 3.11`
    3. Install a package (this will modify `Pipfile` and `Pipfile.lock`)
    * `pipenv install some_package`
    * `pipenv install some_package=1.0`
    1. If a `Pipfile.lock` file already exists, you can install the packages from it.
    4. If a `Pipfile.lock` file already exists, you can install the packages from it.
    * `pipenv sync`
    1. Update packages
    5. Update packages
    * `pipenv update` > updates all packages
    * `pipenv update <package>` updates a single package and its sub-dependencies
    3. Access the pipenv shell (necessary for enabling the virtualenv and for your script to find the installed packages).
    6. Access the pipenv shell (necessary for enabling the virtualenv and for your script to find the installed packages).
    * `pipenv shell`
    4. Exit a pipenv shell.
    7. Exit a pipenv shell.
    * `exit`
    5. Install all dependencies to the system, avoiding virtualenvs entirely (useful for deployment in containers)
    8. Install all dependencies to the system, avoiding virtualenvs entirely (useful for deployment in containers)
    * `pipenv install --system --deploy` > Use this in your Dockerfile.

    # Installing pipenv on Docker Dev Environment
  14. ziritrion revised this gist Apr 8, 2024. 1 changed file with 28 additions and 7 deletions.
    35 changes: 28 additions & 7 deletions pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -36,21 +36,42 @@
    16. Create a new environment and install dependencies listed in YML file.
    * `conda env create -f environment.yml`

    # Pipenv
    # Pipenv + Pyenv

    `pipenv` does not have built-in package search; make sure you search for the packages at [PyPI](https://pypi.org/).
    `pyenv` is a Python version manager. It allows you to install and manage multiple Python versions.

    `pipenv` is a Python virtualenv management tools. `pipenv` does not have built-in package search; make sure you search for the packages at [PyPI](https://pypi.org/).

    ### Installation

    1. `pyenv`
    * https://github.com/pyenv/pyenv
    * `pyenv` can be installed with either Brew or with the automatic installer script.
    * For Windows, there is `pyenv-win` but I have not tested it.
    1. `pipenv`
    * https://pipenv.pypa.io/en/latest/index.html
    * Install locally for your user with `pip install pipenv --user`

    ### Usage

    The environments are based on the folder you're on. There is no need to manually name them, and there is no environment activation to take care of per se.

    1. Install the Python version you need
    * `pyenv install 3.11`
    1. Install a package (this will modify `Pipfile` and `Pipfile.lock`)
    * `pipenv install some_package`
    * `pipenv install some_package=1.0`
    1. Access the pipenv shell (necessary for enabling the virtualenv and for your script to find the installed packages).
    1. If a `Pipfile.lock` file already exists, you can install the packages from it.
    * `pipenv sync`
    1. Update packages
    * `pipenv update` > updates all packages
    * `pipenv update <package>` updates a single package and its sub-dependencies
    3. Access the pipenv shell (necessary for enabling the virtualenv and for your script to find the installed packages).
    * `pipenv shell`
    1. Exit a pipenv shell.
    * `deactivate`
    3. Install all dependencies to the system, avoiding virtualenvs entirely (useful for deployment in containers)
    * `pipenv install --system --deploy`
    4. Exit a pipenv shell.
    * `exit`
    5. Install all dependencies to the system, avoiding virtualenvs entirely (useful for deployment in containers)
    * `pipenv install --system --deploy` > Use this in your Dockerfile.

    # Installing pipenv on Docker Dev Environment

  15. ziritrion revised this gist Dec 17, 2021. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -60,4 +60,5 @@ The environments are based on the folder you're on. There is no need to manually
    * Install pip

    sudo apt install python3-pip
    * Derp
    * Install pyenv. Follow instructions here: https://github.com/pyenv/pyenv-installer
    * Install pipenv. Follow instructions here: https://pipenv.pypa.io/en/latest/
  16. ziritrion revised this gist Dec 17, 2021. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -57,4 +57,7 @@ The environments are based on the folder you're on. There is no need to manually
    * Update apt

    sudo apt update && sudo apt upgrade

    * Install pip

    sudo apt install python3-pip
    * Derp
  17. ziritrion revised this gist Dec 17, 2021. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -55,5 +55,6 @@ The environments are based on the folder you're on. There is no need to manually
    # Installing pipenv on Docker Dev Environment

    * Update apt
    sudo apt update && sudo apt upgrade

    sudo apt update && sudo apt upgrade

  18. ziritrion revised this gist Dec 17, 2021. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -50,4 +50,10 @@ The environments are based on the folder you're on. There is no need to manually
    1. Exit a pipenv shell.
    * `deactivate`
    3. Install all dependencies to the system, avoiding virtualenvs entirely (useful for deployment in containers)
    * `pipenv install --system --deploy`
    * `pipenv install --system --deploy`

    # Installing pipenv on Docker Dev Environment

    * Update apt
    sudo apt update && sudo apt upgrade

  19. ziritrion revised this gist Dec 17, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -48,6 +48,6 @@ The environments are based on the folder you're on. There is no need to manually
    1. Access the pipenv shell (necessary for enabling the virtualenv and for your script to find the installed packages).
    * `pipenv shell`
    1. Exit a pipenv shell.
    * `deactivate`
    * `deactivate`
    3. Install all dependencies to the system, avoiding virtualenvs entirely (useful for deployment in containers)
    * `pipenv install --system --deploy`
  20. ziritrion revised this gist Dec 17, 2021. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -47,5 +47,7 @@ The environments are based on the folder you're on. There is no need to manually
    * `pipenv install some_package=1.0`
    1. Access the pipenv shell (necessary for enabling the virtualenv and for your script to find the installed packages).
    * `pipenv shell`
    1. Install all dependencies to the system, avoiding virtualenvs entirely (useful for deployment in containers)
    1. Exit a pipenv shell.
    * `deactivate`
    3. Install all dependencies to the system, avoiding virtualenvs entirely (useful for deployment in containers)
    * `pipenv install --system --deploy`
  21. ziritrion revised this gist Nov 2, 2021. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -31,6 +31,10 @@
    * `conda config --show channels`
    14. Remove conda-forge channel
    * `conda config --remove channels conda-forge`
    15. Create an environment file from your current environment.
    * `conda env export --from-history > environment.yml`
    16. Create a new environment and install dependencies listed in YML file.
    * `conda env create -f environment.yml`

    # Pipenv

  22. ziritrion revised this gist Nov 2, 2021. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -25,6 +25,12 @@
    * `conda update -n my_env_name --all`
    11. List installed packages in current environment
    * `conda list`
    12. Add conda-forge channel
    * `conda config --add channels conda-forge`
    13. Check conda channels
    * `conda config --show channels`
    14. Remove conda-forge channel
    * `conda config --remove channels conda-forge`

    # Pipenv

  23. ziritrion revised this gist Nov 2, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -12,8 +12,10 @@
    5. If pip doesn't work with a fresh conda install:
    * `conda install pip`
    6. Install project dependencies (listed in requirements.txt file)
    * `conda install --file requirements.txt`
    * `pip install -r requirements.txt`
    7. Delete an old environment
    * `conda remove --name my_env_name --all`
    * `conda env remove -n my_env_name`
    8. Update conda
    * `conda update conda`
  24. ziritrion renamed this gist Oct 8, 2021. 1 changed file with 17 additions and 1 deletion.
    18 changes: 17 additions & 1 deletion conda.md → pythonenvs.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # Conda

    1. Create a virtual environment
    * `conda create --name my_env_name python=3.8` or whatever Python version you may need.
    2. List available envs (2 different ways
    @@ -20,4 +22,18 @@
    10. Update all packages in another env
    * `conda update -n my_env_name --all`
    11. List installed packages in current environment
    * `conda list`
    * `conda list`

    # Pipenv

    `pipenv` does not have built-in package search; make sure you search for the packages at [PyPI](https://pypi.org/).

    The environments are based on the folder you're on. There is no need to manually name them, and there is no environment activation to take care of per se.

    1. Install a package (this will modify `Pipfile` and `Pipfile.lock`)
    * `pipenv install some_package`
    * `pipenv install some_package=1.0`
    1. Access the pipenv shell (necessary for enabling the virtualenv and for your script to find the installed packages).
    * `pipenv shell`
    1. Install all dependencies to the system, avoiding virtualenvs entirely (useful for deployment in containers)
    * `pipenv install --system --deploy`
  25. ziritrion revised this gist Sep 8, 2021. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion conda.md
    Original file line number Diff line number Diff line change
    @@ -18,4 +18,6 @@
    9. Update all packages in the current environment
    * `conda update --all`
    10. Update all packages in another env
    * `conda update -n my_env_name --all`
    * `conda update -n my_env_name --all`
    11. List installed packages in current environment
    * `conda list`
  26. ziritrion created this gist Sep 7, 2021.
    21 changes: 21 additions & 0 deletions conda.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    1. Create a virtual environment
    * `conda create --name my_env_name python=3.8` or whatever Python version you may need.
    2. List available envs (2 different ways
    * `conda env list`
    * `conda info --envs`
    3. Activate virtual env
    * `conda activate my_env_name`
    4. Deactivate current environment
    * `conda deactivate`
    5. If pip doesn't work with a fresh conda install:
    * `conda install pip`
    6. Install project dependencies (listed in requirements.txt file)
    * `pip install -r requirements.txt`
    7. Delete an old environment
    * `conda env remove -n my_env_name`
    8. Update conda
    * `conda update conda`
    9. Update all packages in the current environment
    * `conda update --all`
    10. Update all packages in another env
    * `conda update -n my_env_name --all`