1

So I updated my mac a while ago to ventura 13.3.1 and ever since it messed up my python path, I can't use Pycharm (it can't locate a valid interpreter path), and I can't use pip as well.

When I try to run python, it always prompts to install the Xcode tools even though they are already installed:

xcode-select: Failed to locate 'python', requesting installation of command line developer tools.

when I run pip it says:

zsh: /usr/local/bin/pip: bad interpreter: /usr/bin/python: no such file or directory

Path of python: /usr/local/bin/python

Path of python3: /Library/Frameworks/Python.framework/Versions/3.12/bin/python3

I have multiple versions of python installed on various places either through brew, macports, website installation, virtualenv, conda etc. and I think it all messed up once I updated.

How do I remove all of python stuff and start again from a clean slate?

2 Answers 2

1

You mentioned that you use brew. I'd start by running brew doctor and reading up on their suggestions. It should discover enough to give you steps on how to comprehensively re-install xcode tools (If I recall correctly, they give you instructions on how to nuke the existing install). xcode tools comes with a copy of python (since Apple dropped default installing python in macOS 12).

If that doesn't fix your problem, it might be because of stale code that's in your ~/.zprofile or ~/.zshrc files -- like path entries that should be removed or changed. Outside of that, it could be broken symbolic links that need to be deleted or updated.

One program I highly recommend to juggle all the different python versions is pyenv

That link describes it better than I can and provides instructions to install (it uses brew, and then you edit your .z* files). Once installed, you can use it to change the default version of python, and even install additional versions.

Pycharm is a different issue -- Hopefully your issue will be fixed from the steps above and that your projects aren't also hosed expecting python to exist in hard-coded places that don't exist anymore. Conda is supposed to protect you against that though, so crossing my fingers for ya! :)

One final note -- apps ran from the dock only know about the contents in ~/.zprofile -- if you made modifications there, afaik, the only way to refresh that systemwide is to log out and log back in again.

Otherwise, from the terminal, you can use source ~/.zprofile and/or source ~/.zshrc to get updated settings applied.

0

python and pip not being found is good - what has happened here is that these are for python 2 which was end of life in 2020 and Apple have removed them.

So you now need to use python3 and pip3 everywhere, and I think that fixes your issues.

In using Pycharm etc you will just need to reselect your python interpreter, I think this can be global or per project - the per project ones should use conda or virtualenv ones.

The Xcode-select error suggest that Xcode command line tools are not installed so you need to reinstall them. This will give a /usr/bin/python3

I suspect other issues are from /usr/local/bin/pip - I suspect that this is from homebrew. If so uninstall python from homebrew (again this is python 2 I think)

If you have macports python as well uninstall one of Homebrew or MacPorts - macports does officially support having both - it does work in some cases but you have to debug the issues or your own and your question shows that you do not have enough knowledge to do this.

Your current python3 can be fixed by editing your shell files.

2
  • Expecting Apple's python3 to be installed is what gets the prompt for the CLT, because that's what contains Apple's python3. Feb 29 at 14:45
  • @MarcWilson The OP says python not python3 for the CLT issue
    – mmmmmm
    Mar 1 at 18:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .