Pip/ipython install

I am trying to install pip onto my mac (OS Catalina v10.15.4). I’m unable to install pip and it’s making it very difficult to install ipython since I can’t get pip. When putting the code into my terminal this is what I get. Any help would be appreciated!

luke@Lukes-Air ~ % curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1884k 100 1884k 0 0 9919k 0 --:–:-- --:–:-- --:–:-- 9971k
luke@Lukes-Air ~ % pip --version
Traceback (most recent call last):
File “/usr/local/bin/pip”, line 11, in
load_entry_point(‘pip==21.0.1’, ‘console_scripts’, ‘pip’)()
File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py”, line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py”, line 2843, in load_entry_point
return ep.load()
File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py”, line 2434, in load
return self.resolve()
File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py”, line 2440, in resolve
module = import(self.module_name, fromlist=[‘name’], level=0)
File “/Library/Python/2.7/site-packages/pip-21.0.1-py2.7.egg/pip/_internal/cli/main.py”, line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax

From the errors messages it looks like you’re using python 2.7 which is probably the system python. Part of that error even uses f-strings which aren’t supported in Python2 so I’m not surprised there are errors (it might need an earlier version of pip).

You’d have a much better time adding a new Python install, ideally with a newer version python3.+ since python2 is no longer officially supported.

There are some cc articles that mention the basic install, see
https://www.codecademy.com/articles (use dropdown menu for Python)
https://www.codecademy.com/articles/install-python3
Or you can hunt for install guidance elsewhere if you prefer.

1 Like

I’ve made sure that python3 is set as the default in my system but I am still getting the same error message:

luke@Lukes-Air ~ % curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1884k 100 1884k 0 0 5964k 0 --:–:-- --:–:-- --:–:-- 5964k
luke@Lukes-Air ~ % python --version
Python 3.9.1
luke@Lukes-Air ~ % pip --version
Traceback (most recent call last):
File “/usr/local/bin/pip”, line 11, in
load_entry_point(‘pip==21.0.1’, ‘console_scripts’, ‘pip’)()
File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py”, line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py”, line 2843, in load_entry_point
return ep.load()
File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py”, line 2434, in load
return self.resolve()
File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py”, line 2440, in resolve
module = import(self.module_name, fromlist=[‘name’], level=0)
File “/Library/Python/2.7/site-packages/pip-21.0.1-py2.7.egg/pip/_internal/cli/main.py”, line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax

There’s still an issue with pip working with a different python install. Without messing around with the path at present do any of the following commands work-

python -m pip --version
python3 -m pip --version
pip3 --version

Yes, they all work and have the same output path:

luke@Lukes-Air ~ % python -m pip --version

pip 20.2.3 from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip (python 3.9)

luke@Lukes-Air ~ % python3 -m pip --version

pip 20.2.3 from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip (python 3.9)

luke@Lukes-Air ~ % pip3 --version

pip 20.2.3 from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip (python 3.9)

luke@Lukes-Air ~ %

So with those commands you’re using the version of pip that was installed when you installed python3 (they’re usually bundled together these days). Just avoid using the old pip on its own or it’ll continue using your system python.