Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError DLL load failed importing _tkinter

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.

like image 428
paduraru2009 Avatar asked Jan 04 '12 09:01

paduraru2009


4 Answers

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.

like image 187
David Jacka Avatar answered Nov 13 '22 16:11

David Jacka


Re-install 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!
like image 24
Hossein Avatar answered Nov 13 '22 16:11

Hossein


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

like image 3
Ishani Pandey Avatar answered Nov 13 '22 16:11

Ishani Pandey


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.

like image 3
user2506472 Avatar answered Nov 13 '22 15:11

user2506472