I am trying to install a Python module on a raspberry pi that is running linux. I am using Python 2.7.11 and have tried the following commands:
python -m pip install schedule
python -m easy_install schedule
python2.7 -m pip install schedule
In each case I get the same error message:
Could not import runpy module
I get this same error message no matter what module I try to install. What could be causing this problem? I have been unable to find anything useful from Google searches I've done on the error message.
EDIT:
When I try adding sudo to the command like either of these:
sudo python -m pip install schedule
or sudo /usr/bin/python -m pip install schedule
I get the error:
-sh: sudo: not found
EDIT2:
When I try python -m pip install runpy
I still get:
Could not import runpy module
The runpy module is installed by default during the installation of the environment. So, there might be a problem with the installation of the virtual environment. This happens if the installation was cancelled in between or an old environment was not properly removed and it was overwritten.
The runpy module is used to locate and run Python modules without importing them first. Its main use is to implement the -m command line switch that allows scripts to be located using the Python module namespace rather than the filesystem.
I've encountered the same error, hoping my own experience will do some help. First check your PYTHONPATH (by executing 'echo $PYTHONPATH' in your shell) to see if it is empty. Normally it should be empty. But if it isn't, you have to explicitly put your python corresponding library path to it.
In my own environment, the wrong configuration is:
export PYTHONPATH=/mnt/usb/srv/homeassistant/lib/python3.4/site-packages
and my python location is:
/usr/bin/python
So, I append my python's library path to the configuration(don't forget the ':'):
export PYTHONPATH=/mnt/usb/srv/homeassistant/lib/python3.4/site-packages:/usr/lib/python3.6/site-packages:/usr/lib/python3.6/site-packages
The error is gone now.
The runpy module is installed by default during the installation of the environment.
So, there might be a problem with the installation of the virtual environment. This happens if the installation was cancelled in between or an old environment was not properly removed and it was overwritten.
So, try to re-install the environment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With