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.
It's not pip-specific. It's documented in errno
, specifically:
No such file or directory. This error is mapped to the exception
FileNotFoundError
.
If you didn't know to look for "No such file or directory", you could use os.strerror()
or errno.errorcode
:
>>> import os
>>> os.strerror(2)
'No such file or directory'
>>>
>>> import errno
>>> errno.errorcode[2]
'ENOENT'