Reputation: 79
I have not used python since installing on my Mac OS for a class in probably 2015 (read: beginner. I know nothing about configuring environment/dependency stuff). Recently, I decided to use python again for simple scripting. Scripts were executing but I was unable to import a numpy dependency. I received error messages about my numpy and did a bunch of pip uninstall/reinstall/upgrade/install-ignore numpy stuff. I kept getting the following message:
ImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['/Users/userName/anaconda/lib/python2.7/site-packages/numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.
I decided to address my outdated python; I googled how to do this and ran brew install python as suggested here.
This did not solve the issue. I kept trying answers I found online that had worked for other people, including uninstalling and reinstalling and upgrading pip/pip3. This resulted in an effed up pip. Calling pip -V returns:
from pip._internal.cli.main import main ImportError: No module named pip._internal.cli.main
At this point I realized that my system was looking in this anaconda file for all things python (which I probably installed at some point as a student 5 years ago). Now my pip doesn't work, my python is supposedly v3 according to homebrew, but everything is looking for a highly outdated anaconda file.
I even attempted to update anaconda via their instructions. I get this error:
ImportError: No module named conda.cli
What have I done are there steps I can take to fix these issues?
Upvotes: 0
Views: 607
Reputation: 207853
Zeroth rule... make a backup.
First rule... do not delete anything supplied by Apple. That includes anything under:
/bin
/usr/bin
/Applications
/Library
Second rule... do delete anything from homebrew because you can simply reinstall it later. Find homebrew Python packages with:
brew search python
and look for things with ticks (checkmarks) and delete with:
brew rm XYZ
Third rule... delete anything installed by Anaconda because you can simply reinstall later.
Fourth rule... be aware of what your shell is actually running when you type a command. So, if you want to know which actual Python interpreter you are running when you type python3
for example, run:
type python3
Fifth rule, look at your PATH with:
echo $PATH
If there are any directories for Anaconda, or /opt
or any other junk, alter your PATH to remove them, log out and back in for changes to take effect.
Upvotes: 1