4

After updating macOS Monterey today to 12.6 all my Python projects/scripts have stopped working.

Checking the symlink of a Python binary in one of my project's venv, I see the original to be:
/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9
which is not in path list!? Installed with the macOS update today?

it seems that all the symlinks to Python in the virtual environments of all of my VS Code projects now point to the binary above, and none of the projects work anymore, all with ModuleNotFoundError.

How can I get all my projects to work again?

Background/details:

.bash_profile:

# Setting PATH for Python 3.8
PATH="/Library/Python/3.8/bin:${PATH}"
export PATH

.zprofile:

PATH="/Library/Python3.9/bin:${PATH}"
export PATH

eval "$(/opt/homebrew/bin/brew shellenv)"

.zshrc:

export PATH=$PATH:/Users/xxxx/Library/Python/3.8/bin

The scripts run with venv activated ((venv)...), confirmed with which python which accurately returns the path of Python in venv (though symlinked to the weird path).

When trying to (re)install those libraries, with venv still active, they get installed in root Python with following warning:

WARNING: The scripts f2py, f2py3 and f2py3.9 are installed in '/Users/xxxxxx/Library/Python/3.9/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

I'm using /bin/zsh when run in VS Code. Same from stand-alone terminal window. I shared Bash above as listed in paths.

tried:

echo $PATH

returns (edited for readability):

/opt/homebrew/bin:
/opt/homebrew/sbin:
/Library/Python3.9/bin:
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/usr/local/MacGPG2/bin:
/Library/Apple/usr/bin:
/Users/xxxx/Library/Python/3.8/bin

notes:

  • the last path (/Users/..) seems to be the one used by Bash but not Zsh/VS Code/. This was working as is before the update though.
  • need to add missing path: /Users/xxxx/Library/Python/3.9/bin

checking paths one by one:

  • /opt/homebrew/bin: no Python binary in folder
  • /opt/homebrew/sbin: no Python binary in folder
  • /Library/Python3.9/bin: folder Python3.9 does not exist
  • /usr/local/bin: /usr/local/bin/python found +++
  • /usr/bin: /usr/bin/python3 found +++
  • /bin: no Python binary in folder
  • /usr/sbin: no Python binary in folder
  • /sbin: no Python binary in folder
  • /usr/local/MacGPG2/bin: no Python binary in folder
  • /Library/Apple/usr/bin: no Python binary in folder
  • /Users/xxxx/Library/Python/3.8/bin: no Python binary in folder
  • not returned with echo $PATH / need to be added: /Users/xxxx/Library/Python/3.9/bin also no Python binary in folder
  • not listed but symlinked now in all projects: /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9
n1c
  • 67
  • 1
  • 8
  • A tip I read somewhere: system-installed Pythons/Perls/Rubys/etc are primarily for use by the system. If you want to do development work, install your *own* Python/etc which you have complete control over. – chepner Sep 14 '22 at 20:45
  • so installing again from python.org? And ensuring the path installed has precedence in the path list? Doesn't solve my issue of restoring my existing projects though I believe? – n1c Sep 14 '22 at 21:33
  • I don't know if VS Code provides a way to update your projects in bulk, but https://stackoverflow.com/questions/58562928/how-do-i-update-a-python-virtual-environment-with-venv-to-use-a-newer-version might help. In general, you don't upgrade a virtual environment; you just create a new one. – chepner Sep 14 '22 at 21:50

1 Answers1

0

I had the same issue in VS Code running notebooks. I uninstalled and reinstalled the Jupyter extension. Then when attempting to run a notebook for the first time again, there is a prompt to install jupyter notebook. Once done, all the notebooks are running fine again for all the environments I am using.