Loading dll using cytpes returns WinError 127 - python-3.x

We use a python script to run a camera as part of an experiment. In practice, the python script uses ctypes to load a dll and this is what is used to access the camera functionality. We recently upgraded to a Windows 10 computer, and I now no longer seem to be able to load the dll.
A stripped down version of the relevant script as follows:
PARENT_DIR = os.path.dirname(os.path.realpath(__file__))
os.add_dll_directory(PARENT_DIR)
x = ct_util.find_library('picam_64bit')
self.picam = ct.WinDLL(x)
On the fourth line, the following error is returned:
[WinError 127] The specified procedure could not be found
A few further notes:
The camera works with the manufacturer-supplied executable.
The code was originally written in Python 2.7 and has been migrated to Python 3.8. The same error occurs in both.
This question is clearly relevant. I have made sure that only one version of Python is installed at a time (right now, 3.8), and there is only one version of the dll on the computer.
The third line returns a sensible value, so Python can clearly `see' the DLL, just not load it.

Related

How can I convert this .h5 model to a format my Windows machine can read? (OSError)

The model was originally created in Keras using a remote Linux environment that I no longer have access to. I now need to load the model on my Windows machine (a couple of years later). The program is written in Python if that's relevant.
The error I get:
Exception has occurred: OSError
Unable to open file (bad superblock version number)
File "Directory/file” line 13, in model = load_model('model1.h5')
I've tried installing h5py-2.10.0 so that I could install h5repack to convert the file to a readable format but when I do that, it says that h5repack is unable to open the file.
h5repack error: < 'model1.h5' >: unable to open file
I’m reluctant to try switching my machine over to Linux unless there’s no other solution.
Thanks in advance for your help!

mkl_blas_dgemm_alloc not found in mkl_intel_thread

I developed a a tool in python 3.5 some time ago which currently only uses differential evolution from scipy to do its task. For some reasons I had to change settings on my machine and switch to use python in a virtual environment.
My specs now:
win 10 64 bit
used pip 9.0.1
numpy 1.12.1+mkl
scipy 0.19.0
python 3.6.1
I have a different env using python 2.7 flying around somewhere else.
Now my problem....everytime the differential evolution function gets its first set of data it crashes after returning the differential_evolution step value.
The differential_evolution call can be found under ./libraries/methods/differential_evoluation.py line 76
The pop-up Error is "Entry point 'mkl_blas_dgemm_alloc wasn't found in 'mkl_intel_thread.dll'." And the printed error is "Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll." Please notice that my system language is german therfore the pop-up message was translated by me.
I don't know whether this is relevant but my directory structure is:
>some_place/location1/goal.py
>some_place/location2/env/
I didn't work with virtualenv before and in addition to this i used python 3.5. I'd appreciate any help or instructions on how to add more information to this case to help clarify my problem.
Yours sincerely
OK I'm back with more information. Maybe someone else will stumble uppon it. To be clear: I do not know the fix or reason. I just tried a bunch of stuff.
Using
python 3.5.3,numpy 1.11.1+mkl and scipy-0.18.0 or scipy-0.19.0
made the error disappear. I couldn't try numpy 1.11.1 or 1.11.2 for python 3.6 because this kind soul sadly doesn't offer those versions anymore. I found the 1.11.1 version for python 3.5 somewhere on my disk.
From my testing i can tell that it breaks once i use numpy 1.11.3 or higher. 1.11.1 works fine. Therefore I assume that some changes happened either in numpy between 1.11.1 and 1.11.3 which break it OR in how this kind soul creates/builds his wheels. So I'm going to use python 3.5 for now as i do not have numpy 1.11.1+mkl for python 3.6.
Yours sincerely

Python Leap motion Libraries not working

I am trying to use my Leap motion in Python 3.4, but I cant even get import Leap to work. The python file I am trying to run is on my desktop, along with all the library files (Leap.py, LeapPython.pyd, Leap.dll, and Leap.lib). Whenever I try to run import Leap in my code, the program just throws this:
ImportError: DLL load failed: The specified module could not be found.
I'm not sure what DLL its talking about, I already tried putting msvcp120.dll and msvcr120.dll in the same directory.
I am using Leap Motion SDK Version V2.3.1.31549 on a 64 bit Windows 10 with the 32 bit version of Python 3.4
All help is appreciated.
Thank You!
The Leap Motion SDK only supports Python 2.7.
Some people have reported success using SWIG to regenerate the Python wrapper for Python 3 (the SWIG .i file is included in the SDK). You could also use the LeapC library to to create a Ctypes-based wrapper, which could support multiple versions of Python.

TinyTag import error python 3.3

I have been trying to import tinytag into python to be able to read mp3 tags but I keep receiving the same error. This is the code I am running
from tinytag import TinyTag
tag = TinyTag.get('/some/music.mp3)
print(tag.album)
and the error I recieve from this is
ImportError: No module named 'tinytag'
If anyone could give me any information on how to fix this would be greatly appreciated or can suggest another reader to use that is compatible with python 3.
Like you, I'm new to Python and I struggled with this but I worked it out eventually. I'm sure there is better way, but this worked (on windows, with my examples)
I installed a python module called easy_install (bundled with
setuptools). you can Google this. In the directory \Python26\Scripts you should see an exe file called easy_install if this has worked
Then I downloaded TinyTag to my pc eg
\downloads\tinytag-0.6.1.tar.gz
Then in note pad I wrote a small text file called myinstall.bat with
the contents
easy_install C:/downloads/tinytag-0.6.1.tar.gz
pause
then saved it into \Python26\Scripts and ran it (the pause keeps the
window open so you can see it worked)
Subsequently I started using some software called JetBrains to code with (it's commercial but there is a free edition) and that has an install tool built in which is even easier) I hope this helps

Can not make DDE connection using python. win32ui appears not working

I am new to Python (version 2.7). I have been using for a long time some excel workbooks that uses DDE function to capture "real-time market data" - that is served by one Market Data Provider ("Matriks", if matters).
In a bit to simplify my overall process flow, I decided to bypass this excel workbook thing for data capture, and instead, I decided to use python codes to perform the same task.
The problem is that,
1) I get "error: The server could not be created" when I run the code (provided below) using Pythonwin.
2) and I get "ImportError: This must be an MFC application - try 'import win32ui' first" when I run this very simple code using IDLE.
(and of course, I downloaded and run win32ui.)
Any help is appreciated.
# DDE code
# excel equivalent of this code is: =MTX|DATA!EURUSD.SON
import win32ui
import dde
s=dde.CreateServer()
s.Create("MTX")
c=dde.CreateConversation(s)
c.ConnectTo("DATA","SON")
c.Connected()
c.Request("EURUSD")
# returns
# Traceback (most recent call last):
# File "C:\IQTrader\_script\_obj\DDEClient.py", line 12, in <module>
# import dde
# ImportError: This must be an MFC application - try 'import win32ui' first
The issue is resolved. The very basic reason for the error is the pywin module.
For those facing with the same problem:
1.Delete pythonwin and pywin32_system32 folderes entirely (presumably under C:\Python27\Lib\site-packages)
2.Check your pywin32 version; it should be 214 (not 218) for those using v2.7
3.Download pywin32-214.win32-py2.7 from appropriate resources (one is this: http://sourceforge.net/projects/pywin32/files/pywin32/Build%20214/ )
4.Everything should be fine.
I had a similar problem. I had to:
uninstall Python 2.7 64-bit
install Python 2.7 32-bit
use the pywin32 version 214
Run cmd.exe as administrator so that the c.ConnectTo() connects successfully
However, I am still having the weird problem that I must have Excel open at the same time with a cell holding the value =MTX|DATA!EURUSD.SON for the python script to return a valid quote. Otherwise, I just get "N/A" as the return value.
#Aykut did you run into this issue as well?

Resources