VLC Python Bindings -- Error 193 - python

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.

Related

Python Firebird WinError 193 connection error

import fdb
def main():
con = fdb.connect(dsn='C:\AKINSOFT\Wolvox8\Database_FB\SIRKET.FDB', user='sysdba', password='masterkey')
if __name__ == '__main__':
main()
I wrote a simple code for connecting a Firebird database with Python and fdb. When I run this, I get an winerror 193
Traceback (most recent call last):
File "C:\Users\grand\PycharmProjects\DatabaseTest\main.py", line 9, in <module>
main()
File "C:\Users\grand\PycharmProjects\DatabaseTest\main.py", line 5, in main
con = fdb.connect(dsn='C:\AKINSOFT\Wolvox8\Database_FB\SIRKET.FDB', user='sysdba', password='masterkey')
File "C:\Users\grand\PycharmProjects\DatabaseTest\venv\lib\site-packages\fdb\fbcore.py", line 803, in connect
load_api(fb_library_name)
File "C:\Users\grand\PycharmProjects\DatabaseTest\venv\lib\site-packages\fdb\fbcore.py", line 231, in load_api
setattr(sys.modules[__name__], 'api', ibase.fbclient_API(fb_library_name))
File "C:\Users\grand\PycharmProjects\DatabaseTest\venv\lib\site-packages\fdb\ibase.py", line 1396, in __init__
fb_library = WinDLL(fb_library_name)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 geçerli bir Win32 uygulaması değil
The English error is "[WinError 193] %1 is not a valid Win32 application", and it means you're trying to load a 32-bit DLL in a 64-bit process (or a 64-bit DLL in a 32-bit process). This means that you don't have a valid fbclient.dll on the PATH that matches the bitness of your Python process, but do have one of the wrong bitness.
So, find out if you're using a 32-bit or 64-bit Python (likely 64-bit these days), and use a Firebird installer of the appropriate bitness to install the client library.
If you don't have or don't want fbclient.dll on the PATH, you can also use fdb.load_api(..) or the fb_library_name connection property to specify the path to a fbclient.dll of the appropriate bitness.
As an aside, fdb has been superseded by the firebird-driver library.

OSError: [WinError 126] when importing a library in python

i am using the cubemos skeleton tracking Api (using for extract skeleton keypoints from pictures and videos).
i have a very weird problem:
everything was working fine, until one day, i received this error (also added image):
Traceback (most recent call last):
File "C:/Users/omria/PycharmProjects/skeletonTracking/skeletonTracking.py", line 3, in <module>
from cubemos.skeleton_tracking.nativewrapper import Api, SkeletonKeypoints
File "C:\Users\omria\PycharmProjects\skeletonTracking\venv\lib\site-packages\cubemos\skeleton_tracking\__init__.py", line 1, in <module>
from .nativewrapper import *
File "C:\Users\omria\PycharmProjects\skeletonTracking\venv\lib\site-packages\cubemos\skeleton_tracking\nativewrapper.py", line 28, in <module>
os.path.join(cubemos_dir, "bin", "cubemos_skeleton_tracking.dll")
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
enter image description here
and line 3 is when i'm importing the library:
from cubemos.skeleton_tracking.nativewrapper import Api
another weird thing, is that the problem was fixed randomly without me doing anything, and then it returned again!
i tried reinstalling the cubemos SDK, rebooting the computer, debug, and i really don't know what is the source of this problem.
it seems like its some problem with my OS (i have windows 10, and using python 3.7 and VENV and PIP for the project)
i tried to figure out if the path is the problem, but again, it was working before, and i can't really tell if that is the problem. what do you think is causing this?
i will appreciate any help.
thanks !
I had the same problem using a conda env. Demos worked but not the python sample. I explicitly added %CUBEMOS_SKEL_SDK%\bin to my Path environment since I had nothing before. That got it going. The %CUBEMOS_SKEL_SDK% was set up okay from the start.

cant open programs with ".lnk" extension using subprocess.call function

it seems subprocess.call function just can be used for the files with '.exe' extension.
This is the code i tried for Firefox.lnk in which this is the same code i tried for a git program that has '.exe' extension and worked without error.
import subprocess
subprocess.call('C:/users/m.m/Desktop/Programs/Firefox')
This is the error I get with Firefox.lnk :
Traceback (most recent call last):
File "C:/Users/m.m/PycharmProjects/untitled5/pros.py", line 2, in <module>
subprocess.call('C:/users/m.m/Desktop/Programs/Firefox.lnk')
File
"C:\Users\m.m\AppData\Local\Programs\Python\Python37\lib\subprocess.py",
line 323, in call
with Popen(*popenargs, **kwargs) as p:
File
"C:\Users\m.m\AppData\Local\Programs\Python\Python37\lib\subprocess.py",
line 775, in __init__
restore_signals, start_new_session)
File
"C:\Users\m.m\AppData\Local\Programs\Python\Python37\lib\subprocess.py",
line 1178, in _execute_child
startupinfo)
OSError: [WinError 193] %1 is not a valid Win32 application
Firefox (Without extension) gives me FileNotFoundError: [WinError 2] The system cannot find the file specified.
when i try the code without extension for those programs with '.exe' extension i have no problem but with any program without '.exe' extension i get error... just like firefox that has '.lnk' extension.
To process .lnk files on Windows there is os.startfile() (Windows only) in the standard library.
If you want to add parameters to the command, you can also use the start command. It is a builtin command (no start.exe) therefore a shell is needed to run it.
You can also use shell=True to make this work!
lnk_path = 'C:/users/m.m/Desktop/Programs/Firefox.lnk'
subprocess.call(lnk_path, shell=True)

Python bindings for VLC

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

How to fix this dll loading python error?

I use one c++ dll in my python code.
When I run my python app on my computer, it works fine but when I copy all to another computer this happen:
Traceback (most recent call last):
File "C:\users\Public\SoundLog\Code\Código Python\SoundLog\SoundLog.py", line 9, in <module>
from Auxiliar import *
File "C:\users\Public\SoundLog\Code\Código Python\SoundLog\Auxiliar\DataCollection.py", line 4, in <module>
import SoundLogDLL
File "C:\users\Public\SoundLog\Code\Código Python\SoundLog\Auxiliar\SoundLogDLL.py", line 4, in <module>
dll = cdll.LoadLibrary(os.environ['PUBLIC'] + "\\SoundLog\\DLLs\\ForPython\\SoundLogC++WrapperDLL.dll")
File "C:\Python26\lib\ctypes\__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "C:\Python26\lib\ctypes\__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 14001] The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail
How can I fix this problem so that my python app work in every computer?
Note:
I only need them to work on windows 7 like mine. And I tested on another win7 computer (both 32bits).
You're using a DLL which depends on a Microsoft Visual C++ runtime which isn't installed on the target computer. You have a few options:
Install or copy the Visual C++ runtime libraries to the target computer. Installation is done by adding merge modules to your installer (if you have one) or by running the redistributable installer (vcredist.exe). The various methods are documented here for VS2005 (other versions will be similar).
If you built the DLL, you can change the project settings to statically link the runtime libraries. See this answer to see how this is done.

Categories