I am getting the following error on my Raspberry Pi: No module named pip__main__; 'pip' is a package and cannot be directly executed
When I type in to the terminal: sudo python3 -m pip install mp3play
What is causing this and how can I fix it so that I can install the module mp3play
?
Pip is not only a standalone executable, it is also a python module.
In fact in the python docs it directly recommends using the -m
syntax for installing a package using pip.
See https://docs.python.org/3.5/installing/index.html#basic-usage:
The standard packaging tools are all designed to be used from the command line.
The following command will install the latest version of a module and its dependencies from the Python Packaging Index:
python -m pip install SomePackage
My guess would have been that your system's pip
(the executable) was being shadowed by the python2 version of the pip
executable. But it sounds like you don't have pip (the module) installed such that your python3 executable can find it, so you may need to reinstall pip (the module) specifically.
For that use python3 -m ensurepip
(docs for ensurepip) which will install pip if it is not present from the persepctive of your python3 interpreter.
The other issue could be that it's finding a file, executable or directory called pip
in your current directory, and it is trying to treat that pip
as a module, and it is not in fact a module.
If it's not that I'm not sure. But it is definitely not because pip is not a module.