Coding

Conda vs venv: Which Python Environment Should You Use?

Use venv if your project needs only Python packages from PyPI: it is built into Python, creates a small environment in your project folder, and works with plain pip. Use conda when you need a specific Python version without installing it yourself, or non-Python libraries such as CUDA, MKL or GDAL, because conda installs binary packages for any language into each environment.

Both isolate one project's packages from another's. The difference is how much they isolate, and where the packages come from.

Conda vs venv at a glance

venvconda
Comes withPython itself (since 3.3)A separate install (Miniforge, Miniconda or Anaconda)
IsolatesPython packages onlyPython itself plus any packages, including C/C++ libraries
Python versionWhichever Python created itAny version you request: python=3.11
Package sourcePyPI via pipConda channels (conda-forge, Anaconda's defaults), plus pip if needed
Where environments liveUsually a .venv folder in the projectUsually a central envs folder under the conda install
Lock / share filerequirements.txtenvironment.yml
LicensingPart of Pythonconda is open source; Anaconda's repository has terms for large organizations

What venv actually creates

A venv is a folder with a small config file and a link to an existing Python. The Python documentation lists what python -m venv .venv makes: a pyvenv.cfg whose home key points at the Python that created it, a Scripts folder (bin on Linux and macOS) with a copy or symlink of the interpreter, and its own site-packages directory. Real pyvenv.cfg from Python 3.12.2 on Windows:

home = C:\Program Files\Python312
include-system-site-packages = false
version = 3.12.2
executable = C:\Program Files\Python312\python.exe
command = C:\Program Files\Python312\python.exe -m venv C:\work\.venv

That freshly created environment, with only pip in it, measured 17 MB on disk. Everything outside Python packages comes from your system: the Python interpreter, compilers, and shared libraries such as an installed CUDA toolkit. If a package on PyPI ships a ready-built wheel for your platform, that's fine. If it needs a system library you don't have, pip install fails or tries to compile from source.

For the full venv workflow (activation on every shell, the PowerShell execution-policy error, deactivating), see Python virtual environments with venv.

What conda does differently

The conda documentation describes conda as providing "package, dependency, and environment management for any language". A conda environment is a full prefix: it contains its own Python interpreter and can contain compiled libraries, command-line tools and even non-Python runtimes, all installed as conda packages. That is why it is popular in data science and machine learning, where packages depend on large native libraries.

The trade-off is size: each conda environment carries its own interpreter and libraries instead of pointing at a shared Python, so it takes more disk space than a venv for the same project, and you need conda itself installed first.

The same tasks in venv and conda

Taskvenv + pipconda
Createpython -m venv .venvconda create -n myenv python=3.12
Activate (Windows cmd).venv\Scripts\activate.batconda activate myenv
Activate (PowerShell).venv\Scripts\Activate.ps1conda activate myenv
Activate (bash/zsh)source .venv/bin/activateconda activate myenv
Install a packagepip install requestsconda install requests
Save the environmentpip freeze > requirements.txtconda env export > environment.yml
Recreate elsewherepip install -r requirements.txtconda env create --file environment.yml
List environments(none; they are just folders)conda env list
Deactivatedeactivateconda deactivate
DeleteDelete the .venv folderconda remove --name myenv --all

The conda commands come from the conda documentation; conda was not installed on the machine used to test the venv commands, so no conda output is shown here. Two documented details are worth knowing: conda env export overwrites an existing environment.yml, and conda env export --from-history writes only the packages you asked for, which makes the file more portable between operating systems.

Which one to use

Your situationUse
Web app, CLI tool, scripts, anything with pure-Python or wheel-only dependenciesvenv
A library you will publish to PyPIvenv (your users install with pip)
You need a Python version that isn't installed and can't install itconda
GPU work needing a particular CUDA toolkit per projectconda
Geospatial or scientific stacks with C/Fortran dependencies (GDAL, HDF5)conda
Team already ships an environment.ymlconda
Restricted machine where you can't install anythingvenv (if Python is there)

Mixing pip and conda

Using pip inside a conda environment works, but the two package managers don't coordinate well. The conda documentation's guidance is to install pip into the environment with conda, use pip only after conda has installed everything it can, and if you need to change things later, recreate the environment instead of running conda after pip. Never mix the two the other way round: don't run conda commands inside a venv.

On Linux distributions that mark the system Python as externally managed, both approaches avoid the externally-managed-environment error, because neither installs into the system Python. See fixing pip's externally-managed-environment error.

Miniforge, Miniconda, Anaconda: which conda?

  • Miniforge: a minimal installer from the conda-forge community. Its README states "The conda-forge channel is set as the default (and only) channel", and it also installs mamba, an alternative command-line front end for the same environments.
  • Miniconda: a minimal installer from Anaconda that uses Anaconda's repository by default.
  • Anaconda Distribution: Anaconda's full installer, with a large set of data-science packages preinstalled.

Licensing matters at work. As of October 2026, Anaconda's terms of service require a paid "Business Plan" subscription for for-profit organizations with more than 200 employees or contractors that use Anaconda's platform, and the terms note that Miniconda's access to the platform falls under the same payment rules. Miniforge with conda-forge doesn't use Anaconda's repository. If you are at a large company, check which channels your conda install points at with conda config --show channels.

If an environment behaves strangely

Run where python (Windows) or which python (Linux, macOS) to see which interpreter is actually first on the PATH; an activated conda base environment and a venv can fight over it. Then check python -c "import sys; print(sys.prefix)": it should print the path of the environment you expect. If it doesn't, deactivate everything, activate the one environment you want, and try again. When in doubt, delete the environment and recreate it from requirements.txt or environment.yml; the Python documentation explicitly says environments should be treated as disposable, and the conda documentation recommends recreating an environment rather than patching it after mixing pip and conda.

Frequently asked questions

Can I use pip inside a conda environment?
Yes, but install as much as possible with conda first and use pip only for what conda can't provide. The conda documentation recommends installing pip into the environment with conda, running pip after conda, and recreating the environment rather than going back to conda installs after pip has changed it.
Can venv create an environment with a different Python version?
No. venv always uses the interpreter that runs it. To get Python 3.11 in a venv, you need Python 3.11 installed, then run it: py -3.11 -m venv .venv on Windows or python3.11 -m venv .venv elsewhere. conda, by contrast, downloads the requested Python version into the environment.
Is conda free to use?
The conda tool is open source. What costs money is Anaconda's own package repository for larger organizations: Anaconda's terms require a paid plan for for-profit organizations with more than 200 employees or contractors. Installing from the community conda-forge channel with Miniforge avoids Anaconda's repository.
Should I commit my environment folder to Git?
No. The Python documentation says virtual environments should not be committed to source control and are not portable. Commit requirements.txt (pip) or environment.yml (conda) instead and recreate the environment from it.

Sources