Closed landtree closed 5 years ago
How have you got the lib installed, how do you invoke your script, what is sys.path
and sys.executable
?
I followed the issue thread for the libdbus error.
Running: sudo pip install dbus
I get: Collecting dbus Could not find a version that satisfies the requirement dbus (from versions: ) No matching distribution found for dbus
Running: sudo apt install python-dbus
I get:
Reading package lists... Done Building dependency tree Reading state information... Done python-dbus is already the newest version (1.2.4-1). 0 upgraded, 0 newly installed, 0 to remove and 165 not upgraded.
So I assumed I was have it installed properly.
I invoke the script with: sudo python /home/pi/card_game/pyplayer.py
as for sys.path & sys.executable
sys.path: /home/pi /usr/lib/python2.7 /usr/lib/python2.7/plat-arm-linux-gnueabihf /usr/lib/python2.7/lib-tk /usr/lib/python2.7/lib-old /usr/lib/python2.7/lib-dynload /usr/local/lib/python2.7/dist-packages /usr/lib/python2.7/dist-packages /usr/lib/python2.7/dist-packages/gtk-2.0
sys.executable: /usr/bin/python
I hope this is all the right information. Thank you for a quick response!
The full code of the script:
from omxplayer.player import OMXplayer from time import sleep
player = OMXplayer('/home/pi/card_game/video/reward1.mp4')
player.play() sleep(5) player.pause()
player.quit()
Thanks for the information, how did you install python-omxplayer-wrapper
?
I used the pip line on the docs site: pip install omxplayer-wrapper
You're missing /usr/lib/python2.7/site-packages
in sys.path
which is where python usually installs things. It looks like you have an issue with pip or your python install. Can you install anything else with pip
and import it? e.g. numpy
?
I installed pyserial from pip and I am using that in a different script that works fine.
Interesting, well we need to find out where omxplayer
installed, if at all. Could you attach the logs generated by running:
$ tree .local/lib/python* > user-lib.log
$ tree /usr/lib/python* > system-lib.log
I have the exact same problem as landtree. I installed everything as instructed but get the same ImportError.
Any ideas yet what to do?
@nellapatella if you can provide the output of the tree commands then I can help diagnose the issue
For some reason when I do the tree commands I get nothing...
Sorry, super new to all of this
@nellapatella can you post the exact output of the command? If you haven't got tree installed run sudo apt-get install tree
I get this... nothing else... And tree is installed.
pi@raspberrypi:~ $ tree .local/lib/python2.7 > user-lib.log pi@raspberrypi:~ $ tree /usr/lib/python2.7 > system-lib.log pi@raspberrypi:~ $
Yes, that is correct, I now need the user-lib.log
and system-lib.log
files to be attached to the ticket so I can look at them, >
redirects output to the terminal into a file.
ah! sorry had no idea that was happening. Here they are. [ user-lib.log system-lib.log
Maybe its because I am using Python 3? I read some other threads here that had this issue...?
That would almost certainly be the issue as you have used pip2 to install the package looking at the logs you've provided. Try pip3 install omxplayer-wrapper
if you want to install for python 3.
Awesome! Got it working! Thanks for such a quick response!
Sorry for the late reply, I had a few meetings and then stepped out of the office.
I ran the tree commands.
I cannot see omxplayer
installed anywhere in your python tree... can you try installing it again with sudo pip2 install omxplayer-wrapper
Hello, I too am having the same problems getting the example to work at all. I get The same "No module named 'omxplayer'"
I am running Python3.5.3 on a Rpi Model2. Any help on this is greatly appreciated as this is my only hope at getting a Python program to control OMXplayer.
EDIT: I tried this:
pip3 install omxplayer-wrapper
Here are the log files: system-lib.log user-lib.log
How about the output python3 -c 'import sys; print(sys.path)'
. You have the library installed locally for both 2.7 and 3.5
Thats possible as I followed the instructions and when it did not work found this thread and saw the mention of Python 3 and the install method for that. I then tried that so yes I may have it installed twice. Should I remove the Python 2.7 install, and if yes how do I do that? Sorry for the noob-ness, its because at this I am a noob.
If you provide the output of
python3 -c 'import sys; print(sys.path)'
I might be able to help you pinpoint why you can't import the library.
Here is what is reported back:
Are you launching python with sudo
or as a user different to pi
?
You have the library installed locally for your pi
user, but not globally, so if you execute python with sudo
your PYTHONPATH
won't have the directory containing the omxplayer
lib on it. I suggest you try installing globally if you're executing with a different user sudo pip install omxplayer-wrapper
. If you're using a virtualenv you'll have to reinstall the package in there.
I am launching python within IDLE at the moment as I am still putting the application together. The programming is being done on the Rpi itself. How do I install globally? And do you mean install OMXPLAYER, or the Wrapper?
I'm assuming you already have omxplayer installed.
Try running sudo pip install omxplayer-wrapper
and if you're using python 3: sudo pip3 install omxplayer-wrapper
Yes, I do have it installed. I tried installing it with sudo pip install omxplayer-wrapper which failed, and I then tried sudo pip3 install omxplayer-wrapper, which did install
How did the install fail? What are the outputs of these commands?
python -c 'import omxplayer; print(omxplayer.__version__)'
python3 -c 'import omxplayer; print(omxplayer.__version__)'
I ran this: sudo pip install omxplayer-wrapper
again and this time it did not give back an error....whatever
I ran this:
python -c 'import omxplayer; print(omxplayer.version)'
And this came back:
pi@raspberrypi:~ $ python -c 'import omxplayer; print(omxplayer.__version__)' Traceback (most recent call last): File "<string>", line 1, in <module> File "/home/pi/.local/lib/python2.7/site-packages/omxplayer/__init__.py", line 1, in <module> from omxplayer.player import OMXPlayer File "/home/pi/.local/lib/python2.7/site-packages/omxplayer/player.py", line 18, in <module> from dbus import DBusException, Int64, String, ObjectPath File "dbus.py", line 5, in <module> import pathlib ImportError: No module named pathlib
I ran this: python3 -c 'import omxplayer; print(omxplayer.version)'
and this came back:
pi@raspberrypi:~ $ python3 -c 'import omxplayer; print(omxplayer.__version__)' Traceback (most recent call last): File "<string>", line 1, in <module> File "/home/pi/.local/lib/python3.5/site-packages/omxplayer/__init__.py", line 1, in <module> from omxplayer.player import OMXPlayer File "/home/pi/.local/lib/python3.5/site-packages/omxplayer/player.py", line 18, in <module> from dbus import DBusException, Int64, String, ObjectPath File "/home/pi/dbus.py", line 7, in <module> from omxplayer.player import OMXPlayer ImportError: cannot import name 'OMXPlayer' pi@raspberrypi:~ $
THoroughly confused at this point
I believe your file is called dbus.py
? Is that right? Don't call it that, it conflicts with one of the built-in modules causing a circular import, rename it to something else. If this isn't your file, just delete it so it doesn't exist at /home/pi/dbus.py
.
Have been ill and not at work on this sorry.
From: Will Price [mailto:notifications@github.com] Sent: Wednesday, October 17, 2018 5:19 PM To: willprice/python-omxplayer-wrapper Cc: jamesm330; Comment Subject: Re: [willprice/python-omxplayer-wrapper] No module named omxplayer.player (#117)
Closed #117 https://github.com/willprice/python-omxplayer-wrapper/issues/117 .
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/willprice/python-omxplayer-wrapper/issues/117#event-1910721959 , or mute the thread https://github.com/notifications/unsubscribe-auth/Ap7qBMhQMUj2STokDHP-YMZPkQx9-UL2ks5ul563gaJpZM4Rgmsp .Description: Image removed by sender.
Feel free to reopen if it's an issue.
On Oct 17 2018, at 10:28 pm, jamesm330 notifications@github.com wrote:
Have been ill and not at work on this sorry.
From: Will Price [mailto:notifications@github.com] Sent: Wednesday, October 17, 2018 5:19 PM To: willprice/python-omxplayer-wrapper Cc: jamesm330; Comment Subject: Re: [willprice/python-omxplayer-wrapper] No module named omxplayer.player (#117)
Closed #117 https://github.com/willprice/python-omxplayer-wrapper/issues/117 . — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/willprice/python-omxplayer-wrapper/issues/117#event-1910721959 , or mute the thread https://github.com/notifications/unsubscribe-auth/Ap7qBMhQMUj2STokDHP-YMZPkQx9-UL2ks5ul563gaJpZM4Rgmsp .Description: Image removed by sender.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub (https://github.com/willprice/python-omxplayer-wrapper/issues/117#issuecomment-430795759), or mute the thread (https://github.com/notifications/unsubscribe-auth/AA6-PWwXcv7jP-Phsza4SXg_xkMXmOoKks5ul6DogaJpZM4Rgmsp).
hi i need your help . from omxplayer.player import OMXPlayer
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 305, in _custom_import
module = self._original_import(*args, *kw)
File "/home/pi/.local/lib/python3.5/site-packages/omxplayer/player.py", line 18, in
Issue Report
Description
When running example code get error
Traceback (most recent call last): File "pyplayer.py", line 3, in
from omxplayer.player import OMXplayer
ImportError: No module named omxplayer.player
Problem reproduction
Running example local file code.
Environment details
lsb_release -a
):