0

In Python3.4, I have:

>>>import sys
>>>print(sys.platform)
win32

But the system is absolutely of win64.

Here is a piece of code in tkinter__init__py:

import sys
if sys.platform == "win32":
    # Attempt to configure Tcl/Tk without requiring PATH
    from tkinter import _fix

which leads a ImportError to my code. The traceback:

Traceback (most recent call last):   File "H:/User/Henri/WorkSpace/Python/DeepLearning/Try/Try01/Read_MNIST.py", line 3, in <module>
    import matplotlib.pyplot as plt   File "D:\Python34\lib\site-packages\matplotlib\pyplot.py", line 98, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()   File "D:\Python34\lib\site-packages\matplotlib\backends\__init__.py", line 28, in pylab_setup
    globals(),locals(),[backend_name],0)   File "D:\Python34\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 8, in <module>
    import tkinter as Tk, tkinter.filedialog   File "D:\Python34\lib\tkinter\__init__.py", line 36, in <module>
    from tkinter import _fix   File "D:\Python34\lib\tkinter\_fix.py", line 65, in <module>
    import _tkinter ImportError: DLL load failed: %1 is invalid win32 application。
Joe
  • 41,484
  • 20
  • 104
  • 125
  • Python returns 'win32' for all versions of Windows for compatibility reasons. – Joe May 30 '14 at 13:55
  • 1
    See also: http://stackoverflow.com/questions/2208828/detect-64bit-os-windows-in-python – Joe May 30 '14 at 13:55

1 Answers1

0

You'll have to do some fiddling around to determine if you're running in 64 or 32 bit windows. See this question: How do I determine if my python shell is executing in 32bit or 64bit mode on OS X?

Python is very specific about what sys.platform returns for windows -> 'win32' or 'cygwin'

Determining the version of windows is up to you :D.

Community
  • 1
  • 1
jaime
  • 2,234
  • 1
  • 19
  • 22
  • Thank you. I elaborate my problem with the system version issue. How can I overcome this import error of _tkinter? My python version is 3.4, and unfortunatly there is no matching tkinter module. – John-Annual May 30 '14 at 14:03