I am setting up pip using the official documentation on an Ubuntu 22.04 LTS system, and when I execute the python get-pip.py
command, I get an error message stating:
python3: can't open file '/home/usr/get-pip.py': [Errno 2] No such file or directory
I thought it was an error on my part because python
commands don’t work in Linux distros and I aliased the python3 command:
alias python='python3'
The problem persisted. A quick Google Search led me to this solution and my error was solved.
Afterwards, I did some digging on what [Errno 2] is but all of the material I encountered was hyperfocused on solving this error and not what causes it.
2
Answers
It’s not pip-specific. It’s documented in
errno
, specifically:If you didn’t know to look for "No such file or directory", you could use
os.strerror()
orerrno.errorcode
:The standard linux error codes can be found by running
man 3 errno
or referencing errno(3) — Linux manual page.It means what it says: the file doesn’t exist.
Python commands do work on linux and there was no need to alias
python
here. You ranpython get-pip.py
and python told you that it couldn’t findget-pip.py
. You ran from the current working directory/home/usr/
but python tried to be friendly and show the absolute path of the non-existent file.The instructions told you to download get-pip.py, change to the download directory and then run the command. You must have missed one of those steps.
The solution that worked for you downloaded get-pip.py into the current working directory and executed it. That’s why it worked. It may not have been so wise to
sudo
first as you risk overwriting your platform-installed python as opposed to installing a local python.