Python bindings for VLC - python

I am on Windows, and I wish to use Python Bindings for VLC. I've already downloaded the module from https://github.com/geoffsalmon/vlc-python , and did as per the read me. But, still I'm stuck at importing the module. The error looks like this :
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
import vlc
File "c:\python27\python-vlc-1.1.2\vlc.py", line 173, in <module>
dll, plugin_path = find_lib()
File "c:\python27\python-vlc-1.1.2\vlc.py", line 150, in find_lib
dll = ctypes.CDLL('libvlc.dll')
File "C:\Python27\lib\ctypes\__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found
Any Solution on where to place the module ? My main aim is to play MP3 audio files through vlc, which would be part of some other activity.

I had same problem.
It turns out for me if you have 64bit python, you need 64bit vlc player.
If you have 32bit python, you need 32bit vlc player.
Hope that works for you too.

I paired with 64bit I solved as follows. Of course
# first set the environment which is required from vlc.py
import os
os.environ['PYTHON_VLC_MODULE_PATH'] = """C:\Program Files\VideoLan"""
os.environ['PYTHON_VLC_LIB_PATH'] = """C:\Program Files\VideoLan\VLC\libvlc.dll"""
# now you can import vlc
import vlc

Related

Python: Can't get module sklearn to work... OSError: [WinError 126] The specified module could not be found

I'm using Visual studio and am trying to learn how to use scikit-learn/sklearn. I installed it and all the other packages using 'pip' without any problems.
I literally am only trying to import it. No other code yet.
Whenever I try to import it though, I get the following Error:
Traceback (most recent call last):
File "c:/Users/samir/Code/Machine Learning A-Z/Machine Learning A-Z (Codes and Datasets)/Part 1 - Data Preprocessing/Section 2 Part 1 - Data Preprocessing/Python/data_preprocessing_Samir.py", line 20, in <module>
import sklearn
File "C:\Users\samir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\sklearn\__init__.py", line 82, in <module>
from .base import clone
File "C:\Users\samir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\sklearn\base.py", line 17, in <module>
from .utils import _IS_32BIT
File "C:\Users\samir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\sklearn\utils\__init__.py", line 20, in <module>
from scipy.sparse import issparse
File "C:\Users\samir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\__init__.py", line 130, in <module>
from . import _distributor_init
File "C:\Users\samir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\_distributor_init.py", line 61, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
You need openslide windows libraries. Use either of the links below to obtain the binary.
32-bit: https://github.com/openslide/openslide-winbuild/releases/download/v20171122/openslide-win32-20171122.zip
64-bit: https://github.com/openslide/openslide-winbuild/releases/download/v20171122/openslide-win64-20171122.zip
After installation, open directory to which you installed to, and find the "bin" folder and add it to your windows path.
To add the path to "bin" folder to the Path variable, start the Run box and enter "sysdm.cpl"
This should open up the System Properties window. Go to the "Advanced" tab and click the "Environment Variables" button:
In the "System variable" window, find the "Path" variable and click Edit:
enter image description here
Position your cursor at the end of the Variable value line and add the path to the python.exe file, preceeded with the semicolon character (;). In our example, we have added the following value: ;C:\Python34. (But for you, add the openslide "bin" folder instead)
Close all windows. Now you can run sklearn.

Pyinstaller doesn't recognize docx2pdf library

my issue is that i've been trying to make an exe file with a .py that I created, but it doesn't work. I executed the converted .exe file from the console to see the log and I got this:
Traceback (most recent call last):
File "professors.py", line 10, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 531, in exec_module
File "docx2pdf\__init__.py", line 13, in <module>
File "importlib\metadata.py", line 551, in version
File "importlib\metadata.py", line 524, in distribution
File "importlib\metadata.py", line 187, in from_name
importlib.metadata.PackageNotFoundError: docx2pdf
[6940] Failed to execute script professors
I've been reading about the issue and it seems that pyinstaller doesn't recognize the docx2pdf import. I read in a website that I have to add it in a folder called site-packages, but it is supposed to have another folder inside called pyInstaller, which is not there. I also tried adding the folder manually but it still didn't work. I also tried with the --hidden-imports method but im not sure how to exactly use it.
I will have to apply this to other imports that I have also.
Any ideas? Thanks in advance!
I had a identical issue. I removed lines 7-13 from the docx2pdf module:
try:
# 3.8+
from importlib.metadata import version
except ImportError:
from importlib_metadata import version
__version__ = version(__package__)
and line 119...
print(__version__)
After that, it worked. Modifying the module probably isn't the best solution, and of course I'd recommend backing up the module before modifying it, but I hope it works for you too.

Python can't load libc when importing xfsm module

I'm trying to write Python code to manipulate Xerox FST files, and I've installed the Python bindings for libxfsm and the XFSM library available through http://fsmbook.com. I'm running 64-bit Ubuntu. The installation goes fine, but when I try to import the xfsm module, I get this error:
>>> import xfsm
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/xfsm/__init__.py", line
30, in <module>
import xfsm.errors # So error handler gets installed
File "/usr/local/lib/python2.7/dist-packages/xfsm/errors.py", line
8, in <module>
from xfsm.utils import *
File "/usr/local/lib/python2.7/dist-packages/xfsm/utils.py", line
39, in <module>
libc = cfsm.load_library("c")
File "/usr/local/lib/python2.7/dist-packages/xfsm/cfsm_api.py", line
366, in l oad_library
raise ImportError("%s not found." % libname)
ImportError: c not found.
Inspecting the source code for the Python interface, it looks like it is trying and failing to find libc, and failing, but I am at a loss on how to fix that.
Has anybody else gotten the Python-XFST interface working, or have any idea what's going wrong and how to fix it?
I had same problem on 64-bit Ubuntu 14.04. The problem is it can't find libc. In my case libc on my OS is name libc.so.6(I don't know why, I am new on Ubuntu). But the Python-XFST doesn't recognize it (Detail your can refer to source file)
My solution is simple, just modify xfsm/utils.py file in
**Line 39** : libc = cfsm.load_library("c")
to
**Line 39** : libc = cfsm.load_library("libc.so.6")
Remember to add the path to libc.so.6 in env.

Python, cudamat, and Spyder

I'm trying to use the cudamat library and I can't figure out how to use it from within Spyder. I have included the cudamat folder contents in my working directory, but when I try:
import cudamat as cm
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "cudamat/__init__.py", line 1, in <module>
from cudamat import *
File "cudamat/cudamat.py", line 7, in <module>
_cudamat = ct.cdll.LoadLibrary('libcudamat.so')
File "/usr/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libcudamat.so: cannot open shared object file: No such file or directory
When I run the my script using python from a console window, it works fine. To the best of my knowledge, I have set the working directory of Spyder to the correct location, which contains libcudamat.so.
Any ideas?
(Spyder dev here): You need to start Spyder from a console, so that it can grab its environment variables. I guess cudamat is not installed in a regular location and that's why Spyder can't find it by default.
Note: This is an Spyder limitation (i.e. not being able to read environment variables) that we plan to fix in the future.

VLC Python Bindings -- Error 193

Have downloaded VLC.py, and placed it in my VLC install directory, where libvlc.dll is also present
On typing import vlc
I get the following error
Traceback (most recent call last):
File "C:\Program Files
(x86)\VideoLAN\VLC\vlc.py", line 88,
in
dll = ctypes.CDLL('libvlc.dll') File
"C:\Python27\lib\ctypes__init__.py",
line 353, in init
self._handle = _dlopen(self._name, mode) WindowsError: [Error 193] %1 is
not a valid Win32 application
Any ideas why?
If needed, my config is:
Win7 pro 64 bit
4GB RAM
Reposting my comment as an answer, since it fixed the problem:
I'm going to guess that the problem is trying to load a 32-bit DLL from a 64-bit process. You may be able to fix it by using a 32-bit Python build.

Categories