1

(I'm new here, so please be gentle)

When using topgrade in homebrew (I installed topgrade after installing homebrew with brew install topgrade) on macOS big sur on a 2020 Intel 13" default upper specs MacBook Pro I ran into the following issue:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

Looking for a solution on the web I found this article.

Following the advice I ran xcode-select --install and restarted afterwards.

After running topgrade again I became a bit suspicious when it said:

    ...
Successfully installed pip-21.1.1
    WARNING: You are using pip version 19.2.3, however version 21.1.1 is available.
    You should consider upgrading via the 'pip install --upgrade pip' command.
    ...

but I though well, seems like it updated itself. So I ran topgrade again and it said

WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Requirement already satisfied: pip in ./Library/Python/3.8/lib/python/site-packages (21.1.1)

Since then I've been getting the same answer. I followed the link but found no solution other than the Python workaround, which seems to be a short term solution.

As far as I know have both pip version 19.2.3 as well as 21.1.1 and need to remove the old one right? But how do I do that? And does Requirement already satisfied: pip in ./Library/Python/3.8/lib/python/site-packages (21.1.1) mean it already fixed itself? And what happens if I ignore the problem?

If anyone could help me out it would really be appreciated. While I love tech I've got no coding experience at all in this is just over my head. That you so much!

Edit: I ran the advice given here and got the following results:

which -a python python2 python2.7 python3 python3.6

showed

/usr/bin/python
/usr/bin/python2
/usr/bin/python2.7
/usr/bin/python3

typing python and hitting tab (equivalent to compgen -c python) gave me

python            python2           python2.7-config  pythonw
python-config     python2.7         python3           pythonw2.7

and running locate python after building the database like described gave me a super long list, which wouldn't fit here.

New Question: I don't really understand the steps I'm supposed to take here before running python -m pip, but I don't really see any difference whether or not I do these steps anyway. Can I just run python -m pip without really having a clue what happens?

Second Edit

python -m pip --version gives /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named pip

and python3 -m pip --version gives pip 21.1.1 from /Users/MyName/Library/Python/3.8/lib/python/site-packages/pip (python 3.8)

Regarding the second comment python -V gives Python 2.7.16

and python3 -V gives Python 3.8.2

Also sorry that it's been a while, but we have exams at the moment so I've been kind of busy.

1
  • I have formatted your question lightly for readability and added a relevant link to topgrade (I believe). Please look over the question and make any additional changes you see fit. – Anaksunaman May 12 at 1:20
0

Some thoughts:

As far as I know have both pip version 19.2.3 as well as 21.1.1 and need to remove the old one right?

Regarding removal, not necessarily. While it's certainly more true on Linux, Python is often tightly integrated into *nix-style systems. Messing with a default system installation of Python can (hypothetically) cause failures in key system software (the most visible often being package managers than run Python under the hood).

How do I do that?

Assuming the older version is part of your system's default Python installation, ideally you shouldn't. In any case, it's often better to use any built-in system tools or take other appropriate steps to upgrade to the most recent versions of the right software (Python/pip). The arguable exception to this is any virtual environment or Python application that requires specific versions of Python or any related packages to be installed.

It is probably worth mentioning that while pip 19.2.3 can be used with Python 2 or Python 3, pip 20.3 was the last version to have a .whl (Python prebuilt installation file) supporting Python 2. pip 21.0+ is squarely aimed at Python 3. A history of pip releases is available here.

I followed the link but found no solution other than the Python workaround, which seems to be a short term solution.

The basic advice on that page is solid and will help you avoid problems, assuming you follow it. You should read it carefully.

Note that the reference to using python -m pip as a workaround is somewhat misleading. That form is typically the best way to use pip, independent of the issue you are encountering. It won't necessarily keep you completely out of trouble but, as a rule, using pip by itself often isn't advisable.

Does Requirement already satisfied: pip in ./Library/Python/3.8/lib/python/site-packages (21.1.1) mean it has already fixed itself?

It likely means that you have a current version of pip installed in that installation of Python (./Library/Python/3.8) or whatever it refers to. To really find out what's what, you will likely want to check for multiple installations of Python (as a suggestion, see this Stack Overflow question perhaps for some ideas on how to do that), and then check each installation's version of pip.

Note that, as far as I am aware, Xcode installs its own copy of Python 3 (default python3, pip3) which is separate from the Python 2 installation MacOS has used in the past by default (often python, pip).

What happens if I ignore the problem?

Your computer will crash, turning your screen into the "falling code" from The Matrix and then your system will spontaneously explode. ;)

Seriously, though, I unfortunately don't have an answer for you. You should edit your question with the results of the testing suggested above, which might offer a bit better window into what's happening.

4
  • thanks a million, did so, please check edit – bbvs247 May 12 at 7:35
  • I checked the edit. Thank you for updating. It doesn't appear you have any extra Python installs in your path. I might suggest running python -m pip --version as well as python3 -m pip --version to see the exact versions of pip installed with each one and add the full results to your question as well. In short, this should indicate what version of pip is in use for each installation (and arguably whether any "problem" is actually with your pip installs or potentially something else). – Anaksunaman May 12 at 21:49
  • Regarding new your question, there can be multiple Python instances (interpreters) installed on a system. Each of these are unique. The base installations don't share packages or tools (such as pip). So running python -m pip "as-is" is really only a solution if you know for certain that (in your case) python is referring is not only to Python 3.x but also how that version of Python 3.x relates to whatever topgrade is doing. Note that you can check the general version(s) of Python with ex. python -V and python3 -V respectively. This information could also be helpful if edited in. – Anaksunaman May 13 at 0:27
  • did so, please check – bbvs247 May 23 at 10:45
0

The important thing is this:

Figure out what installation of Python you want to be using, make sure that's the one you get when you just type python at the prompt, and make sure that the pip you get when you just type pip points to that same installation.

Apple is moving away from having a default installation of scripting languages including Python, but so far they still come with one - that you don't have permission to upgrade without turning off System Integrity Protection. So the usual advice of "just keep the system install upgraded" is harder to do on Macs.

You get a completely different version when you install Xcode, and it doesn't supply a python binary at all, only one called python3.

My advice is to install python with Homebrew, so you have full control over it, but it also doesn't provide a python, at least not one linked by default. You have to make that link yourself. But I think you should - symlink all the 3-less Homebrew python binaries to /usr/local/bin; and put /usr/local/bin in your PATH before any other system-type locations.

So these steps, basically:

brew install python
ln -s /usr/local/opt/python/libexec/bin/* /usr/local/bin
/usr/local/bin/python -mpip install --upgrade pip

Then in your shell startup file (~/.bash_profile or ~/.zprofile or ~/.bashrc or ~/.zshrc) make sure that /usr/local/bin comes first in your PATH with something like this:

PATH=/usr/local/bin:${PATH#/usr/local/bin:}

Then quit your shell and start a new one and then you should be good to go.

5
  • typing pipresults in zsh: command not found: pip and typing pythonresults in WARNING: Python 2.7 is not recommended. This version is included in macOS for compatibility with legacy software. Future versions of macOS will not include Python 2.7. Instead, it is recommended that you transition to using 'python3' from within Terminal. Python 2.7.16 (default, Feb 28 2021, 12:34:25) [GCC Apple LLVM 12.0.5 (clang-1205.0.19.59.6) [+internal-os, ptrauth-isa=deploy on darwin Type "help", "copyright", "credits" or "license" for more information. >>> and an infinite calculation – bbvs247 May 22 at 11:44
  • Did you run the three commands and modify your .zprofile and restart your terminal window? – Mark Reed May 22 at 14:34
  • no, I though I couldn't run them because pip and python didn't point to the same installation. Also thanks for the quick reply and helping in general! – bbvs247 May 23 at 17:05
  • also, are these all separate ones?: brew install python ln -s /usr/local/opt/python/libexec/bin/* /usr/local/bin /usr/local/bin/python -mpip install --upgrade pip – bbvs247 May 23 at 17:07
  • yes. three separate commands. first install the Homebrew version of Python. Then create links so that you have a 'python' in /usr/local/bin that points to that Homebrew installation. Upgrade pip using that python. Then change your $PATH so you get that python when you type just python. – Mark Reed May 24 at 2:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.