willprice / python-omxplayer-wrapper

:tv: Control OMXPlayer, the Raspberry Pi media player, from Python
http://python-omxplayer-wrapper.readthedocs.io
GNU Lesser General Public License v3.0
253 stars 71 forks source link

No module named omxplayer.player #117

Closed landtree closed 5 years ago

landtree commented 6 years ago

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



| Software | Version |
|----------|---------|
| `python-omxplayer-wrapper` | `0.2.5` |
| `python-dbus' |  1.2.4-1 |
| `python' | `2.7.13` |
| `omxplayer` (`omxplayer --version`) | `5a25a57` |

-------
willprice commented 6 years ago

How have you got the lib installed, how do you invoke your script, what is sys.path and sys.executable?

landtree commented 6 years ago

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:

!/usr/bin/env python

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()

willprice commented 6 years ago

Thanks for the information, how did you install python-omxplayer-wrapper?

landtree commented 6 years ago

I used the pip line on the docs site: pip install omxplayer-wrapper

willprice commented 6 years ago

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?

landtree commented 6 years ago

I installed pyserial from pip and I am using that in a different script that works fine.

willprice commented 6 years ago

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
nellapatella commented 6 years ago

I have the exact same problem as landtree. I installed everything as instructed but get the same ImportError.

Any ideas yet what to do?

willprice commented 6 years ago

@nellapatella if you can provide the output of the tree commands then I can help diagnose the issue

nellapatella commented 6 years ago

For some reason when I do the tree commands I get nothing...
Sorry, super new to all of this

willprice commented 6 years ago

@nellapatella can you post the exact output of the command? If you haven't got tree installed run sudo apt-get install tree

nellapatella commented 6 years ago

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:~ $

willprice commented 6 years ago

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.

nellapatella commented 6 years ago

ah! sorry had no idea that was happening. Here they are. [ user-lib.log system-lib.log

nellapatella commented 6 years ago

Maybe its because I am using Python 3? I read some other threads here that had this issue...?

willprice commented 6 years ago

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.

nellapatella commented 6 years ago

Awesome! Got it working! Thanks for such a quick response!

landtree commented 6 years ago

Sorry for the late reply, I had a few meetings and then stepped out of the office.

I ran the tree commands.

system-lib.log usr-lib.log

willprice commented 6 years ago

I cannot see omxplayer installed anywhere in your python tree... can you try installing it again with sudo pip2 install omxplayer-wrapper

jamesm330 commented 5 years ago

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

willprice commented 5 years ago

How about the output python3 -c 'import sys; print(sys.path)'. You have the library installed locally for both 2.7 and 3.5

jamesm330 commented 5 years ago

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.

willprice commented 5 years ago

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.

jamesm330 commented 5 years ago

Here is what is reported back:

python3_info.txt

willprice commented 5 years ago

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.

jamesm330 commented 5 years ago

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?

willprice commented 5 years ago

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

jamesm330 commented 5 years ago

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

willprice commented 5 years ago

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__)'

jamesm330 commented 5 years ago

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

willprice commented 5 years ago

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.

jamesm330 commented 5 years ago

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.

willprice commented 5 years ago

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).

supremeinternational commented 4 years ago

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 from dbus import DBusException, Int64, String, ObjectPath File "/usr/lib/python3/dist-packages/thonny/backend.py", line 305, in _custom_import module = self._original_import(args, **kw) File "/home/pi/dbus.py", line 2, in from omxplayer.player import OMXPlayer ImportError: cannot import name 'OMXPlayer'