samtal
Posts: 23
Joined: Thu Dec 24, 2015 2:49 pm

rasp3B Python Streach, "No module named 'uinput'"

Thu Aug 30, 2018 9:36 am

Hi,
I have been struggling with this for more than a day, yet, after seemingly successful installation of the uinput package I still get the message "No module named 'uinput'" in my (any) sketch.
As can be seen in the attached, the installation went nicely (I have tried several installation methods, all OK).
I updated and upgraded the python, rebooted and did anything else I could think of, but for no avail.
I have seen several forums' threads on the matter, non of which solved my problem.
I searched (locate) for the uinput.py and uinput.pyc files, but they do not seem to be present, and the uinput module does not show in the modules list (pip list)
The only thing I can think of is that the uinput will not run with Python Stretch.
Can anyone help me out with this?

Image
Attachments
Python UINPUT install.jpg
Python UINPUT install.jpg (191.24 KiB) Viewed 2268 times
Python UINPUT install.jpg
Python UINPUT install.jpg (191.24 KiB) Viewed 2268 times

DirkS
Posts: 10770
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: rasp3B Python Streach, "No module named 'uinput'"

Thu Aug 30, 2018 9:52 am

I just installed the module for Python 2 and I don't get an error when importing it.
samtal wrote: "No module named 'uinput'" in my (any) sketch.
I can see a single quote in front of uinput in the error message. Is that a transcription error or is that quote present in the source code?
Forget this bit. I need glasses :roll:
Last edited by DirkS on Thu Aug 30, 2018 10:04 am, edited 1 time in total.

User avatar
davidcoton
Posts: 6813
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: rasp3B Python Streach, "No module named 'uinput'"

Thu Aug 30, 2018 9:54 am

So you installed python-pip and python3-pip -- which were both already installed.
Same for libudev-dev.
Then you used pip to install the Python2 version of python-uinput.
My guess is you then tried to call uinput from python3.
So you need

Code: Select all

pip3 install python-uinput
Location: 345th cell on the right of the 210th row of L2 cache

samtal
Posts: 23
Joined: Thu Dec 24, 2015 2:49 pm

Re: rasp3B Python Streach, "No module named 'uinput'"

Thu Aug 30, 2018 10:16 am

Nop.
With all hope,...Tried the python3, just the same.
I probably need more questions/advice.

DirkS
Posts: 10770
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: rasp3B Python Streach, "No module named 'uinput'"

Thu Aug 30, 2018 10:21 am

samtal wrote:
Thu Aug 30, 2018 10:16 am
Nop.
With all hope,...Tried the python3, just the same.
I probably need more questions/advice.
That does not make clear what you just did...
- did you run your script with python2
- did you install the module for python 3 and then run your script with python 3?

Can you post the output of

Code: Select all

pip freeze
pip3 freeze
Best is to copy & paste the text instead of trying to post screenshots / images.

User avatar
B.Goode
Posts: 14295
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: rasp3B Python Streach, "No module named 'uinput'"

Thu Aug 30, 2018 11:04 am

I can't explain the technical background, but in my experience using

Code: Select all

pip{3} install some_package
will often silently fail to do what is expected in a simple shell environment. (It does work in a python venv virtual environment.)

Maybe you need

Code: Select all

sudo pip{3} install some_package
?

DirkS
Posts: 10770
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: rasp3B Python Streach, "No module named 'uinput'"

Thu Aug 30, 2018 11:20 am

B.Goode wrote:
Thu Aug 30, 2018 11:04 am
I can't explain the technical background, but in my experience using

Code: Select all

pip{3} install some_package
will often silently fail to do what is expected in a simple shell environment. (It does work in a python venv virtual environment.)
Good catch! I did not notice the lack of 'sudo'. It means the module will be installed locally; just for the current user. IIRC it will be in ~/.local/lib
The python script will certainly fail if you run that script with sudo...

So if you use

Code: Select all

pip install module
Then use that module in a script and run

Code: Select all

sudo python script-using-module
will throw a module not found error

So to OP: I would run

Code: Select all

pip uninstall python-uinput
sudo pip install python-uinput
and then try again.
BTW: also try to run your script without 'sudo'

samtal
Posts: 23
Joined: Thu Dec 24, 2015 2:49 pm

Re: rasp3B Python Streach, "No module named 'uinput'"

Thu Aug 30, 2018 11:36 am

After changing to 'pip3 install uinput' as suggested and reboot it came to life, and no error now.
I'll try to implement the uinput with the hope it will run now.


Thanks.

Return to “Troubleshooting”