importerror dll load failed python

I have a situation very much like the one at ImportError: DLL load failed: %1 is not a valid Win32 application, but the answer there isn’t working for me.

My Python code says:

But that line throws the error shown in the title of this question.

I have OpenCV installed in C:libopencv on this 64-bit machine. I’m using 64-bit Python.

My PYTHONPATH variable: PYTHONPATH=C:libopencvuildpython2.7 . This folder contains cv2.pyd and that’s all.

My PATH variable: Path=%OPENCV_DIR%in;. This folder contains 39 DLL files such as opencv_core246d.dll .

OPENCV_DIR has this value: OPENCV_DIR=C:libopencvuildx64vc11 .

The solution at ImportError: DLL load failed: %1 is not a valid Win32 application says to add «the new opencv binaries path ( C:opencvuildinRelease ) to the Windows PATH environment variable». But as shown above, I already have the OpenCV binaries folder ( C:libopencvuildx64vc11in ) in my PATH. And my OpenCV installation doesn’t have any Release folders (except for an empty one under build/java).

Any ideas as to what’s going wrong? Can I tell Python to verbosely trace the loading process? Exactly what DLL’s is it looking for?

In Windows, I created a Conda virtual environment with the command

Once it is created, I activated the virtual environment and went into a python interpreter. When trying to import numpy, I get the following error:

Any ideas what is going on here? Thanks!

5 Answers 5

Unlike @Rafael, for me, libiomp5md.dll wasn’t the issue. I installed Dependency Walker to investigate what was going on. Even though the dll versions were different, but Dependency Walker said it was okay.

What was wrong though, was that mkl_intel_thread.dll had warnings (red icon). If you’re using Win 8++, ignore the api-win and ext-ms issues as Dependency Walker wasn’t updated for new Windows versions and doesn’t recognise Windows new APIs.

My solution is to copy all mkl_*.dlls from the former to the latter:

I was able to import numpy and sklearn after that.

I’m using python 2.7.2 and windows 7. I searched through internet, helps and other sources but i can’t find an answer to my problem.

One of my source imports tkinter , and this one imports _tkinter . At this moment it say ImportError DLL load failed :

I searched _tkinter and i found it in Python27/libs as a lib file.

On many sites it says to install tk/tcl or tkinter , but I don’t find a separate installation for windows.

Using Windows x86 MSI Installer (2.7) from http://www.python.org/getit/releases/2.7/. In windows 7 64-bit. The python version is 32 bit.

12 Answers 12

I was getting this error while trying to use matplotlib in a simple application.

Uninstall Python and remove its folder from your C-Drive. Download and Install 64bit python. Follow this to install pip on your machine. http://www1.cmc.edu/pages/faculty/alee/cs40/penv/installFlaskOnWindows.html This was finally what worked for me

I had a similar problem importing Tkinter on Windows 7 64-bit — seems that the 64-bit library was still in the libs folder from a previous 64-bit python install.

Uninstalling 64-bit python properly and then repairing with the 32-bit installer fixed the problem for me — you don’t need to use 64-bit python.

If this still doesn’t work, there is another simple solution:

  1. Uninstall your current python. Delete Python27 folder entirely from your C: drive.
  2. Download and install the 64-bit version of Python from http://www.python.org/download/.
  3. Next time do not mix your 32-bit application with 64-bit OS whenever a 64-bit choice for the application is available!

I had the same issue and was able to uninstall Python 2.7 (using the Windows 7 ‘uninstall’ service) and then reinstall it from here: python-2.7.6.msi

Also, if you’re concerned about ensuring 64bit conformance across your python libraries then you may find the following library list site to be a great resource. It has numerous 64bit versions of python libraries.

Please don’t reinstall Python for this. A simple fix can resolve this issue as below:

  1. Find the matplotlibrc file at Python27Libsite-packagesmatplotlibmpl-datamatplotlibrc
  2. Open using notepad
  3. Change the backend parameter to ‘backend: Qt5Agg’

And it will be solved. No need to reinstall.

SOLVED without reinstalling anything:

1-add these 3 lines to your setup.py :

2- copy tcl86t.dll and tk86t.dll from C: DLLs to (where you have batch file, setup.py).

3- add «include_files»: [«tcl86t.dll», «tk86t.dll»] to option in your setup.py, something like:

note: if you didn’t find tcl86t.dll and tk86t.dll in DLLs folder as mentionned in step 2, then try again to search for it,but using research tab in DLLs folder this time.

I had a similar problem. My Python version was 2.7.12 and 64bit and I was using Windows 10, 64bit OS. I tried to import Tkinter and what I got back was

I uninstalled Python and removed all traces of it. I then installed Python 2.7.14 (32bit) and this seems to have solved my problem. I don’t get this error message any longer.

I have a lot of installed python packages on my machine so I did not want to unistall and reinstall the whole python, I did as follow and the problem was solved:

Change your C:Python27 home folder to another name, for example C:Python27_old

Install a new Python27 on your computer (32 bit)

Copy tcl and DLLs folder from the fresh installed python to the old one (Before this step make a copy of tcl and DLLs of C:Python27_old to recover it if you face any problem in the next steps)

C:Python27 cl Copy and replace to C:Python27_old

C:Python27DLLs Copy and replace to C:Python27_old

  1. Delete the C:Python27
  2. Rename the C:Python27_old to the C:Python27

Please pay attention to get a backup form your tcl and DLLs folder to recover it in case you face any further problem.

Источник: computermaker.info

Техника и Гаджеты
Добавить комментарий