Made a simple hello.py to test the python API code but I am having problems with the error below, all my python paths are set up correctly and I have placed the activator.dll in the same folder as the LexActivator.py but it keeps returning an error in the ctypes library
Does anybody know how to fix this or am I doing something completely wrong here
Thanks
Traceback (most recent call last):
File “C:/Users/philb/PycharmProjects/Cryptlex/Hello.py”, line 2, in
import LexActivator
File “C:\Users\philb\PycharmProjects\Cryptlex\LexActivator.py”, line 39, in
library = load_library(get_library_path())
File “C:\Users\philb\PycharmProjects\Cryptlex\LexActivator.py”, line 33, in load_library
return ctypes.cdll.LoadLibrary(path)
File “C:\Python36\lib\ctypes_init_.py”, line 426, in LoadLibrary
return self.dlltype(name)
File "C:\Python36\lib\ctypes_init.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
Thanks for the updated code, I have tried this but it is still producing the same error, I put print statement in that shows it gets the correct path see below.
C:\Users\philb\PycharmProjects\Cryptlex
File “C:/Users/philb/PycharmProjects/Cryptlex/LexActivator.py”, line 48, in
library = load_library(get_library_path())
File “C:/Users/philb/PycharmProjects/Cryptlex/LexActivator.py”, line 37, in load_library
return ctypes.cdll.LoadLibrary(path)
File “C:\Python36\lib\ctypes_init_.py”, line 426, in LoadLibrary
return self.dlltype(name)
File "C:\Python36\lib\ctypes_init.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
PS C:\Users\philb\PycharmProjects\Cryptlex> python hello.py
C:\Users\philb\PycharmProjects\Cryptlex
Traceback (most recent call last):
File “hello.py”, line 2, in
import LexActivator
File “C:\Users\philb\PycharmProjects\Cryptlex\LexActivator.py”, line 48, in
library = load_library(get_library_path())
File “C:\Users\philb\PycharmProjects\Cryptlex\LexActivator.py”, line 37, in load_library
return ctypes.cdll.LoadLibrary(path)
File “C:\Python36\lib\ctypes_init_.py”, line 426, in LoadLibrary
return self.dlltype(name)
File "C:\Python36\lib\ctypes_init.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
PS C:\Users\philb\PycharmProjects\Cryptlex>
This error can also happen if VS2010 runtime is not already installed in the system (which usually is for Windows 7 and above)
LexActivator has dependency of VS2010 runtime. If the runtime dlls are not present in the system, they should be placed in parallel to LexActivator.dll if you plan to ship them in the installer of your product.
Just as a further update, I then tried the alternative approach of dropping the 2 runtime dll’s in parallel and I got a better result as below
Trial days left: 1.9905914150938133
hello world
I then removed the installed runtime and the code failed again
So it looks like you need to install it AND use the 2 dll’s in parallel, this is going to be a problem for users who do not already have the runtime installed and they then download the product unless the product is packaged in msi and installs the runtime firsts?
Not to mention if the 2 dll’s are updated by MS then this could also be an issue
In order to be safe, just include the dlls with your package, that’s what is usually done
You don’t need to install the runtime if two dlls are in the same directory as LeActivator. Windows first checks for the runtime in the directory of the file being executed, if it doesn’t find the runtime dll’s then only it looks for the system installed dll’s.
So the safest option is, if you can’t make installation of runtime part of your setup, to ship dll’s with your setup.