简体   繁体   中英

How do I uninstall all my python packages?

I have previously had a good working version of Python 3.6.0 on my macOS Sierra, that included modules like matplotlib .

However, I had the need of learning an image processing program, thus I wanted to learn openCV. I tried following this link to download and install openCV. In the process I have downloaded the following programs:

  1. Xcode
  2. Homebrew
  3. Python 2.7.10
  4. Python 3.6.1

I found that I could import the cv2 module in my IDLE, however I could no longer import matplotlib in IDLE. Things are very messy with the 3 versions on Python on my macOS Sierra, and I would like to remove everything related to Python, so that I can start afresh, installing Python again, and hopefully install openCV on the same version of Python that has all the other modules that I was previously using.

I recommend using conda ( https://conda.io/miniconda.html ) to manage your python environments and installed packages. It made my life soooo much better.

eg

$ conda create -n project_1_env python=3.5
$ source activate project_1_env
# project 1 uses python 3.5, and I install packages using `conda install <package>

$ conda create -n project_2_env python=2
$ source activate project_2_env
# project 2 uses python 2.X, and when I activate this environment
# the python 3.6 project-1 doesn't impact me at all

As well as python versions, conda lets you install specific version of packages for different virtual conda environments.

If you are using the Homebrew versions of Python, you can just uninstall them and reinstall.

## Uninstall python & python3 packages. We use ignore-dependencies
## so the uninstaller will allow this; it's okay, we're going to reinstall
## right away anyway.

brew uninstall --ignore-dependencies python3
brew uninstall --ignore-dependencies python

## This will remove all of your locally installed Python packages.

rm -rf /usr/local/lib/python?.?

## And now reinstall the main Python packages.

brew install python python3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM