Phyton ImportError DLL load failed importing _tkinter python importerror dll load failed,python importerror dll load failed

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:

 Traceback (most recent call last): File "NERO/show_image.py", line 13,
 in <module> import Tkinter File "C:\Python27\lib\lib-tk\Tkinter.py", line 38,
 in <module> import FixTk File "C:\Python27\lib\lib-tk\FixTk.py", line 65,
 in <module> import _tkinter ImportError: DLL load failed: %1 is not a valid Win32 application.
 2012-Jan-04 12:27:21.889374 (M) [python] Finished process 

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.

Answer:1

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

Answer:2

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.

Answer:3

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

  1. Find the matplotlibrc file at Python27\Lib\site-packages\matplotlib\mpl-data\matplotlibrc
  2. Open using notepad
  3. Change the backend parameter to 'backend: Qt5Agg'

And it will be solved. No need to reinstall.

Answer:4

SOLVED without reinstalling anything:

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

...
import os
os.environ['TCL_LIBRARY']= r'C:\<your python folder>\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\<your python folder>\tcl\tk8.6'
...
setup(
... 
) 

2- copy tcl86t.dll and tk86t.dll from C:\<your python folder>\DLLs to <your project folder>(where you have batch file, setup.py).

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

options= { 'build_exe':{'packages':[.....], "include_files": ["tcl86t.dll", "tk86t.dll"]}},

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.

Answer:5

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

ImportError: DLL load failed: %1 is not a valid Win32 application

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.

Answer:6

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:

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

  2. Install a new Python27 on your computer (32 bit)

  3. 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\tcl Copy and replace to C:\Python27_old

C:\Python27\DLLs 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.

Answer:7

Removing 64 bit python and doing a repair on 32 bit python worked for me. OS: 64 bit Windows Server 2008.

Answer:8

I also met this issue, because I use 64-bit python. Maybe python 64-bit doesn't have a good support.

My way is to solve it:

  1. Uninstall python 64-bit.
  2. Install python 32-bit.
  3. Uninstall the 64-bit package. pip uninstall xxx.
  4. Install the 32-bit package. pip install xxx.
Answer:9

For Windows 10,

  1. Uninstall all versions of Python
  2. Install Python 3.x (your latest version) with PATH variable
  3. python -mpip install -U matplotlib
  4. Install Python x.x (your other versions) without PATH variable

Done. Try running your scripts again.

Answer:10



  1. python importerror dll load failed
  2. python importerror dll load failed access is denied
  3. python importerror dll load failed 1
  4. python importerror dll load failed while importing
  5. python importerror dll load failed cv2
  6. python importerror dll load failed while importing win32api
  7. python importerror dll load failed numpy
  8. python importerror dll load failed the specified path is invalid
  9. python importerror dll load failed win32api
  10. python importerror dll load failed pyqt5
  11. python importerror dll load failed matplotlib
  12. python importerror dll load failed win32
  13. python importerror dll load failed opencv
  14. python importerror dll load failed while importing pyodbc
  15. python tensorflow importerror dll load failed
  16. python gdal importerror dll load failed
  17. windows python importerror dll load failed
  18. python pil importerror dll load failed
  19. python 2.7 importerror dll load failed
  20. python debug importerror dll load failed

In Django it's common to do the following MyModel.objects.filter(id__in=[huge array]) However it's not very efficient as described in the following answer here: https://dba.stackexchange.com/...

In Django it's common to do the following MyModel.objects.filter(id__in=[huge array]) However it's not very efficient as described in the following answer here: https://dba.stackexchange.com/...

Are Decimal dtypes available in numpy? >>> import decimal, numpy >>> d = decimal.Decimal('1.1') >>> s = [['123.123','23'],['2323.212','123123.21312']] >>> ss = ...

Are Decimal dtypes available in numpy? >>> import decimal, numpy >>> d = decimal.Decimal('1.1') >>> s = [['123.123','23'],['2323.212','123123.21312']] >>> ss = ...