2

Sorry for the repeat, if any, but this is driving me nuts. I ran through a few upgrades of homebrew, in the past, and all python scripts I used to use were running fine, post python updates, meaning the upgrades got all necessary site-packages properly accounted for.

Upgrade today (same mechanism: brew update && brew upgrade && brew cleanup --prune=all), and I see my new python version at 3.12.2 having replaced my previous 3.11, but missing tons of stuff in /usr/local/lib/python3.12/site-packages (as compared to 3.11). Some of them are the praw ones, thus the obvious "No module named 'praw'" when trying to run a python script dependent on it.

I do recall having had a similar issue, a while ago, which I thought I fixed with some simple pip install --upgrade praw or python -m pip install --upgrade praw, but these are now coming back with the "error: externally-managed-environment".

Any ideas how I could fix this?

1 Answer 1

1

This is a result of PEP 668, which Homebrew has followed along with. It is now documented here.

This PEP proposes a mechanism for a Python installation to communicate to tools like pip that its global package installation context is managed by some means external to Python, such as an OS package manager. It specifies that Python-specific package management tools should neither install nor remove packages into the interpreter’s global context, by default, and should instead guide the end user towards using a virtual environment.

So. As of Python 3.12, Homebrew is following PEP 668. It is not broken. Your choices are:

  • Install Homebrew-packaged copies of the modules you want. If Homebrew does not package them, then you can work to add them to Homebrew.

  • Create a venv, and use pip to install the modules you want inside the venv. Activate the venv when you want to use it.

5
  • Maybe it‘s covered in one of the links, but what should the OP now do to update the libraries?
    – nohillside
    Feb 27 at 16:44
  • Install the Homebrew-packaged copies of the software/libraries, or create a venv and install with pip there. This is where Python is going. Feb 27 at 17:56
  • The question ends with „Any ideas how I could fix this?“, adding the steps to do so would for sure help.
    – nohillside
    Feb 27 at 17:59
  • OP here: it would, indeed, help to be directed to a fix. Feb 27 at 22:13
  • Who'd have thought that the experience of working with Python could get worse?
    – Wibbly
    Mar 23 at 2:22

You must log in to answer this question.

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