0

Currently, I feel like my Python ecosystem is out of whack. Several years ago, I had shared my computer with someone else, and now I am discovering that my machine has many versions of Python scattered about. From what I could find, starting from Macintosh HD:

  • anaconda

  • Applications/Python 3.6

    • Contains IDLE, Python Launcher, etc...
  • Library/Python/2.7/site-packages

    • This contains things like pip and wheel (I am unsure what this is)
  • Library/Frameworks/Python.framework/Versions

    • This contains two folders, 3.5 and 3.6.
  • System/Library/Frameworks/Python.framework/Versions

    • Inside here there are many alias folders, all which point to 2.7

Is all of this supposed to be normal? I am trying to run Python from the terminal, yet I have been getting messages such as ImportError: No module named site. pip has also not been working.

Is there a way for me to reset the Python on my machine to just that which comes with macOS? I feel like starting over from a blank slate would be helpful, since I want to get things setup in some type of comprehendible way (e.g. a way in which I've set things up so I know what is on my machine instead of many random things put on it by another).

Quotable
  • 101
  • 1
  • 5
  • I had the exact same issue a few weeks ago. My solution wasn't ideal - I reset everything - but I am glad I did it. Check out my answer to my own question, where I go into a bit more detail https://stackoverflow.com/questions/61913284/how-do-i-configure-python-and-organise-my-interpreters – jda5 Jun 02 '20 at 19:33

1 Answers1

1

This is very normal. you have a preinstalled python2.7 which comes with macOS and another one "Anaconda" which has installed manually. You first need to check what is your default python path (version) on your macOS, I mean if you are using anaconda or the default pre-installed python2.x. To remind you can check like below:

python --version
output (for me): Python 3.7.6

then if you want to change it to another version/or use another version under conda you can check these two answeres of mine.

How to add anaconda to PATH? and here:

How to set the default python3 to python3.7?

It is normal that when you install a package for your default python version you don't expect it to be installed on the other one too. Normally it is better to install python2.x as an environment of conda and switch between two environments with "conda activate py2" and "conda deactivate" to go back to your default version. for each of them, you need to be in the environment and then use pip. if pip is not working, it may need to be installed. On macOS, as you remember, you can use

brew update
brew install pip

or "easy-install" instead of brew (or whatever you use for installation).

Anya Samadi
  • 673
  • 1
  • 5
  • 13
  • Your answer seems like it would have solved my problem. What I ultimately did was uninstall anaconda, and then it allowed me to use the default python – Quotable Jun 05 '20 at 01:59
  • Yeah that is also a solution. Thanks. I saw that you have a python 3.x along side anaconda it is the one now left, that is good. But try not to use python2.7 any more. – Anya Samadi Jun 05 '20 at 03:31