Cannot Import GST in Python

帅比萌擦擦* 提交于 2019-11-28 10:37:36

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.

user1488844

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.

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.

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")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!