Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot uninstall 'numpy'

I've been trying to install astropy and at the end of the installation I get this message:

Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

I have tried: pip uninstall numpy and then I get the same message. I have Python 2.7.10 in a macOS High Sierra version 13.10.5

like image 311
Sara Coutiño De León Avatar asked Jun 21 '18 23:06

Sara Coutiño De León


People also ask

How do I uninstall Numpy and install it again?

While importing we detected an older version of numpy in ['c:\users\paperspace\anaconda3\envs\tensorflow10\lib\site-packages\numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.

How do I uninstall PIP?

To use pip to uninstall a package locally in a virtual environment: Open a command or terminal window (depending on the operating system) cd into the project directory. pip uninstall <packagename>


1 Answers

This doesn't directly answer your question, but that's because you're asking the wrong question.

Astropy requires Python 3.5 or 3.6. Trying to get it working with Apple's pre-installed Python 2.7 is a waste of time. You might be able to get an old version working this way, but not by using the installation instructions on astropy.org, and it won't be supported even if you do.


The easy solution is to just Install the latest Anaconda 5.x with Python 3.6, because it comes with Astropy built in.


The almost-as-easy solution is to install Python 3.6 from either a python.org binary installer, or Homebrew, and then use pip3 or, better, python3 -m pip to install everything, as explained on the Astropy install page.


Either way, before doing anything else, you want to get back to a clean slate. In particular, you do not want pip, or any other scripts, attached to Apple's Python 2.7; they will only cause confusion. Assuming you can't reinstall macOS from scratch, the best way to do this is:

  • Look in /Library/Python/2.7/site-packages and delete everything there except for README and Extras.pth.
  • Look in /usr/local/bin for symlinks to anything in that site-packages. (If you don't know much about using Unix, try this command: ls -l /usr/local/bin | grep 2.7.) You'll probably have pip and pip2.7 here, and probably nothing else. But whatever you have here, delete it.

Now, when you install Python 3.6, the only thing named pip anywhere will be that Python 3.6's pip. You still want to use pip3 or python3 -m pip, but if you screw up and type pip by accident, it won't break anything.


Also, you should strongly consider using a virtual environment. See the Python Packaging Authority's User Guide (or the Anaconda docs, if you went that way) for more on this.

like image 55
abarnert Avatar answered Oct 09 '22 07:10

abarnert