Home > Back-end >  Python installed in multiple paths, is this bad?
Python installed in multiple paths, is this bad?

Time:09-22

I am newish to python and Mac and may have messed up when installing python. Will this cause future errors?

Also why are some paths listed multiple times?

~ % where python3
/opt/homebrew/bin/python3
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
/opt/homebrew/bin/python3
/usr/local/bin/python3
/usr/bin/python3
/opt/homebrew/bin/python3
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
/opt/homebrew/bin/python3
/usr/local/bin/python3
/usr/bin/python3

CodePudding user response:

First, what are these?

  1. /opt/homebrew/bin/python3 — this was installed by Homebrew.

  2. /Library/Frameworks/whatever — This was probably installed by an installation package from the Python website.

  3. /usr/bin/python3 — this one probably came with Xcode.

If you want Xcode installed, you're probably not going to get rid of (3), so you just have to get used to it being there. (1) and (2) are a bit redundant together, and if you use Homebrew for other things, there's a decent probability that it will pull in Python anyway as a dependency for something else, so you might as well keep (1) and get rid of (2).

As for why they are listed multiple times, my guess would be that your PATH environment variable contains some directories multiple times. Checking this is easy — just do echo $PATH — but fixing it will, I’m afraid, require some debugging of your shell startup files to figure out where the duplicates come from.

(Personally, I keep both the Homebrew-installed one, which I never use or install packages for directly, and the /Library/Frameworks one which is the one I use. The advantage of this is that when Homebrew suddenly decides to change a lot of things around, my stuff stays put. However, having an extra Python around certainly increases the risk for confusion, so I don’t particularly recommend this unless you know what you are doing.)

(So why not just use the Xcode installed one? Well, for starters, I don't like mucking about in /usr/bin if I can avoid it... it looks like pip for that would install stuff inside /Applications/Xcode which... just no.)

CodePudding user response:

Try running which rather than where.

Thats the one that counts.

Recommendation: install via homebrew (which you seem to be using already) or macports. Then use virtualenv to assign a specific python executable to each project.

  • Related