I'm trying DolphinDB python API to subscribe a stream table from our DolphinDB cluster. But as I run import dolphindb it reports
ImportError: DLL load failed: The specified module could not be found.
As I read the readme for a second time, I found that only Anaconda python is supported, because of some issue of DLL loading.
But I cannot use Anaconda for some reason, so is there any workaround?
The c++ version python api is based on DolphinDB's c++ api. On windows platform, c++ api is compiled by mingw so that the runtime requires mingw's core dll. The non-Anaconda doesn't come with mingw runtime and hence failed to import the DophinDB python api.
The new version of python api has included mingw's required libraries. Please check it out.
Related
I am developing python library in C++ using pybind11. The problem is that python 3.7/3.6 works well, but
python 3.8 cannot be imported. This is the error when importing the library( assume the library name is mylibrary).
ImportError: DLL load failed while importing mylibrary: The specified module could not be found.
Why Python3.8 can be built in pybind11, but cannot be imported ?
It could be that your C++ python library itself depends on a shared library / DLL. Python 3.7/3.6 would search for DLLs in PATH or the current working directory, but this is no longer the case in Python 3.8:
https://docs.python.org/3.8/whatsnew/3.8.html#ctypes
If this is the problem, you can add use add_dll_directory() to tell Python 3.8 where it should look for the DLLs.
I have a Python script that I want to run in the Azure Automation engine. It imports a few packages, one of which is lxml. There are a lot of platform variations available from the Python Package Index and I can't find any documentation from Azure about which platform I should be using.
Choosing the wrong version provides the following error through the Azure portal:
Orchestrator.Activities.PythonPackageExtractException: Error while extractinig Python package: Unexpected file structure in .whl file for python package lxml. It is likely that the package is for an unsupported platform.
at Orchestrator.Activities.SetModuleActivity.ExecuteInternal(CodeActivityContext context, Byte[] moduleContent, String moduleName, ModuleLanguage moduleLanguage, Guid moduleVersionId, String modulePath)
at Orchestrator.Activities.SetModuleActivity.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
It seems I'm not the only one who's had trouble figuring out which version / platform to use for setting up lxml. Based on this Stack Overflow question, I tried running the following in the Automation environment:
import platform
print(platform.architecture())
This gave me the result ('64bit', 'WindowsPE'), which was enough to guess that I needed the library with win_amd64.whl as the postfix. Sure enough, that worked.
So, if you're importing libraries into the Azure Automation engine, make sure they're tagged as cp27 and made for the win_amd64 platform.
I'm trying to get libarchive module working in python 3.4 on windows.
I've installed libarchive-c with pip and all went ok but whenever I try to import it into my code or even to run it alone I'me getting error:
OSError: [WinError 126] The specified module could not be found
This is coming from ffi.py from the code below:
libarchive_path = os.environ.get('LIBARCHIVE') or find_library('archive')
libarchive = ctypes.cdll.LoadLibrary(libarchive_path)
I've never used ctypes before but if I understand correctly it is looking for external DLL. So found and installed http://gnuwin32.sourceforge.net/packages/libarchive.htm also I've added C:\Program Files (x86)\GnuWin32\bin to my %PATH% in environmental variables but it still cannot load the module. As it does not give me the name I'm not sure what module it is looking for.
What am I missing?
(disclaimer) I contribute to https://github.com/Changaco/python-libarchive-c and I maintain https://github.com/nexB/scancode-toolkit
Both contain a ctypes binding for libarchive, though ScanCode is for extraction only.
My answer here is for python-libarchive-c, but ScanCode contains some of the DLL you are looking for so I am lacing in a bit of both.
To get python-libarchive-c going on Windows you need a libarchive DLL and its deps that can then be loaded.
There are no pre-built DLLs bundled in python-libarchive-c but I have prebuilt Windows binaries for another project here:
https://github.com/nexB/scancode-toolkit/tree/develop/src/extractcode/bin/win-32/bin
The corresponding source code is there: https://github.com/nexB/scancode-thirdparty-src
And you have MinGW32 build instructions there if you want to rebuild from source yourself: https://github.com/nexB/scancode-thirdparty-src/blob/master/libarchive/build.sh#L47
In general to load a DLL from a path -- assuming that the var libarchive contains the full path to that DLL -- use this:
lib = ctypes.CDLL(libarchive)
Now this is for Scancode. For python-libarchive-c, you could try to set the LIBARCHIVE variable to point the path of your DLL with:
set LIBARCHIVE="C:\.....\libarchive.dll"
Then start Python, import the library and use it.
NB: I did not test this (yet) , but this should work. IF not please file a bug.
I did not run any test on Python 3.4 either. I use primarily Python 2.7.
But the DLL and the code is not Python 2.7-specific at all.
FWIW, the way scancode loads the library is a tad more engaged since it can from the same code load DLLs Win/Linux/Mac for specific 32 or 64 bits archs using conventional locations. You can see the code in action there:
https://github.com/nexB/scancode-toolkit/blob/develop/src/extractcode/libarchive2.py#L64
ScanCode is NOT using python-libarchive-c ATM yet but a different/custom ctypes binding focused on a more specific use case of extraction only. At least it gives you access to a Win DLL and its deps (or instruction a build them) and an example on how to load it correctly.
/HTH
I've spent last 2 days trying to launch examples from Boost.Python with the "ImportError: DLL load failed: The specified module could not be found" error, while trying to load compiled (using bjam) pyd modules. I was using Windows 7 x64, Python 2.7 x64 with Boost 1.47. I've followed up different answers on StackOverflow and other sites incl. fresh installs (Python 32 and 64 bit, Boost precompiled), manual Boost's libraries building, DLL checks with dependency walker and so on, with no luck. I registered to share the solution, which worked here and which I hope may help someone, struggling with the same error ;)
Two solution, no need to use regedit
add BOOST_PYTHON_STATIC_LIB marco when build your dll. It will let
boost.python static link to your dll file rather than dynamic load
in runtime.
add boost.python dll to PATH or copy it to same dir where your dll locate
The problem was with the KB2264107 Windows update (http://support.microsoft.com/kb/2264107), "messing" with DLL search routine (security fix). Setting the registry value [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager] : CWDIllegalInDllSearch to 0, allowed to properly load DLL files and properly import .pyd modules. This may also happen on other Windows versions.
my soluition is download microsoft visual c++ 2015 redistribute
https://www.microsoft.com/en-us/download/details.aspx?id=48145
i've built a com component which utilizes libxml2 python bindings , the build is successfull but when i try to register the component i get "specified module could not be found , unable to load python dll" this is the error i get when the component is built using the bundle files option set as 1
if i build the component with bundle files set as 3 ,then i get a different error saying that the component was loaded but the call to DllRegisterServer Failed with error code 80040201
if the libxml2 import is removed all works fine.
any help wold be simply great.
thanks
Most likely, regsvr32.exe which registers you COM component couldn't find a DLL that your COM component needs.
I'm not familiar with Python COM components but is there some way you can run depends.exe on it? This is the usual way to track down binary dependency problems.