Require pip to install packages in virtual environment

Require pip to install packages in virtual environment

March 4, 2024

A frequently heard piece of advice in improving Python development practice is using virtual environments to install dependencies. Virtual environments isolate your dependencies per project to protect you from annoying version conflicts.

You can restrict pip to only install in virtual environments by running

pip config set global.require-virtualenv true

This updates your global pip config file.

If you need to install a package globally for a command line tool (like csvkit), I recommend using pipx or uv tool install. This tool creates an isolated environment for the package and puts it on your system path.

Last updated on

Please submit corrections and feedback...