Cannot Import GST in Python
Asked Answered
F

4

1

I'm in a quandary. I'm following the following tutorial (specifically, 6.4.2)

http://majorsilence.com/pygtk_audio_and_video_playback_gstreamer

I'm running Python 2.7, PyGTK 2.24, and GStreamer WinBuilds 10.7 (the main installer and the SDK).

When I try and compile the program, I get the following error:

Traceback (most recent call last): File "", line 1, in import gst File "C:\Program Files\OSSBuild\GStreamer\v0.10.6\lib\site-packages\gst-0.10\gst__init__.py", line 193, in from _gst import * ImportError: DLL load failed: The specified module could not be found.

How do I get the gst module to import? (Mind you, I checked, and pygst DOES import.)

Thank you in advance!

Ferriter answered 2/8, 2011 at 5:3 Comment(0)
D
7

This is because you are using Python 2.7, and the GST default is 2.6. This is really easy to fix:

Go to C:\Program Files\OSSBuild\GStreamer\v0.10.6\sdk\bindings\python\v2.7\lib

and copy

gstreamer-0.10 and site-packages to

C:\Program Files\OSSBuild\GStreamer\v0.10.6\lib, replacing any existing files.

Then delete the file C:\Program Files\OSSBuild\GStreamer\v0.10.6\lib\gstreamer-0.10\libgstpython-v2.6.dll (or change the extension to .dllx or something).

Now it should work.

Alternatively to changing GST to suit Python 2.7, you could just use Python 2.6.

EDIT: After attempting to install Gstreamer on a new computer, I found that I could not import pygst until I removed the extra backslash from C:\Program Files\OSSBuild\Gstreamer\v0.10.7\lib\site-packages\ in PYTHONPATH. I believe this may have been your problem all the way along.

Dendriform answered 7/8, 2011 at 1:11 Comment(12)
I have no "v2.7 directory" by default. Should I create it?Ferriter
So your saying that C:\Program Files\OSSBuild\GStreamer\v0.10.6\sdk\bindings\python\v2.7\lib doesn't exist? If not, install v0.10.7, because that definitely has it (as I'm using it). Otherwise you can fish around and see if you have a folder named v2.7 somewhere else.Dendriform
Uninstalled 10.6 and installed 10.7. I was able to follow your instructions exactly. Only now, Python won't recognize either PyGST OR GST. What is going on?Ferriter
Would you mind updating your question to include the error you get with v0.10.7? I might be able to help more with an exact error. For now though, you can try repairing OSSBuild and Python from their installers. Also, if you don't mind using Python 2.6, you can use it with GST no problem (generally).Dendriform
And have you installed v0.10.7 for both the SDK and GST?Dendriform
Yes, I have both installed. This morning, PyGST does import, but the error is the same for GST. I'm hesitant to downgrade at this point, but I'll keep that in the back of my mind. I also tried repairing Python 2.7 from its installer, and OSSBuild was a fresh install.Ferriter
The last thing I can recommend is renaming libgstpython-v2.7.dll to libgstpython-v2.6.dll in the folder C:\Program Files\OSSBuild\GStreamer\v0.10.7\lib\gstreamer-0.10. If libgstpython-v2.7.dll doesn't exist, that is the problem, and you will probably have to find it somewhere in the v2.7 folder. Also, if you are using 64-bit Python (on a 64-bit system), I don't think Gstreamer works.Dendriform
It still isn't working. Where exactly did you download your installation of GST?Ferriter
From here: code.google.com/p/ossbuild/downloads/list . I am using LGPL Gstreamer v0.10.7 on Windows XP with Python 2.7.2. I am using pyGObject from ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/2.28 (as I don't need pyGTK). I originally had the exact same problem as you, so I dual-booted Ubuntu and used it for programming with Gstreamer until I figured out how to get it working on Windows.Dendriform
Just remembered: are you using pygst.require('0.10') before you import gst?Dendriform
Still nothing. I'll try downgrading to Python 2.6.Ferriter
Downgraded. It works now. Your last comment especially helped. Thank you! I will award the bounty as soon as I am able to do so.Ferriter
H
4

I had the same problem on Windows 7 with Python 2.7, but the posted solution didn't work. It turned out there was something fishy going on with my path variables, I still don't know why. Here's how I fixed it:

  • I created a file pygst.pth in the Python27 site-packages
  • I copied the path from my environment variables PYTHONPATH, which was C:\Program Files (x86)\OSSBuild\GStreamer\v0.10.7\lib\site-packages\ on my computer, into the file pygst.pth

It was then able to import using the standard method after reopening the interpreter.

Halfback answered 24/9, 2012 at 21:37 Comment(1)
So what will the contents of the file be? I mean the pygst.pth file. Do I just need to copy the path or I need to import some python modules?Umbrella
B
1

In my case the answer was to add the location of the gstreamer binaries to my PATH and my PYTHONPATH (not sure if the second is required)

C:\Program Files (x86)\OSSBuild\GStreamer\v0.10.7\bin

is the location on my machine.

Bergson answered 13/8, 2013 at 13:27 Comment(0)
H
0

Sometime there are other version of same dll in your system with cause the problem. To find out which dll causing the problem, you write a simple python script, loading the dll or pyd file. When execute with python.exe, it will show you a dialog box with much better error message then the "ImportError: DLL load failed: The specified module could not be found."

Here is the python script.

import ctypes
ctypes.CDLL("C:\gstreamer-sdk\0.10\x86\lib\python2.7\site-packages\gst-0.10\gst\_gst.pyd")
Houseclean answered 13/9, 2013 at 23:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.