Disable pip Outside of Virtual Environments

Image for post
Image for post
Photo by Tim Evans on Unsplash

Python packages everywhere!

$ pip install pygments==2.2
Collecting pygments==2.2
Using cached https://files.pythonhosted.org(...).whl
Installing collected packages: pygments
Found existing installation: Pygments 2.4.2
Uninstalling Pygments-2.4.2:
Successfully uninstalled Pygments-2.4.2
Successfully installed pygments-2.2.0

Make sure that pip only runs in a virtual environment

$ pip install requests
ERROR: Could not find an activated virtualenv (required).
gpip() {

Written by

Python consultant, freelancer, and trainer at switowski.com. Writes about productivity, tools, Python, and programming best practices.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store