0

I get the following error when trying to import Tkinter:

    >>> import Tkinter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\lib-tk\Tkinter.py", line 38, in <module>
    import FixTk
  File "C:\Python27\lib\lib-tk\FixTk.py", line 68, in <module>
    import _tkinter
ImportError: DLL load failed: %1 is not a valid Win32 application.

I have a windows 64 bit with python 64 bit.

I came across this when trying to use matplotlib. import matplotlib is working but import matplotlib.pyplot fails with the same error as above. I have tried installing matplotlib from https://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib also. And I have installed Tkinter from there too tkinter3000-1.1.1-cp27-cp27m-win_amd64.whl - as seen from the comments that would not have been necessary.

I have installed Python 2.7.14 from the python website and this version Download Windows x86-64 MSI installer

On starting python on command prompt I get this:

Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit (AMD64)] on win32

but my system type is 64 bit OS x64 based processor.

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
Code_ninja
  • 117
  • 1
  • 10
  • What happens if you `import Tkinter`? If this fails with the same error, the issue has nothing to do with matplotlib. – ImportanceOfBeingErnest Dec 04 '17 at 19:31
  • Yes it is failing – Code_ninja Dec 04 '17 at 19:32
  • Ok, so edit your question to ask about why import Tkinter fails. Remove everything that has to do with matplotlib from it (as it is irrelevant), but provide more information about your python installation. – ImportanceOfBeingErnest Dec 04 '17 at 19:33
  • @ImportanceOfBeingErnest yes done that.Thanks – Code_ninja Dec 04 '17 at 19:45
  • Be specific. What python version do you have? Where did you get it? Why did it not have Tkinter included? What do you mean by *"I have installed Tkinter from there too(The relevant version)"*? There is no Tkinter on the page you link to. – ImportanceOfBeingErnest Dec 04 '17 at 19:51
  • `tkinter3000` is an extention which is not needed at all. (I hope installing that did not break anything.) The fact that it says `win32` [should not disturb you](https://stackoverflow.com/questions/17757819/what-does-the-python-version-line-mean#comment25895630_17757935). But indeed something is strange. Tkinter seems to be there but apparently still something conflicts. – ImportanceOfBeingErnest Dec 04 '17 at 20:08
  • @ImportanceOfBeingErnest Do you need any additional information? – Code_ninja Dec 04 '17 at 20:13
  • I'm really not an expert. If I were you, I would just try to uninstall everything and reinstall python. Python should ship with Tkinter, so it should work out of the box. On the bottom of [this page](https://wiki.python.org/moin/TkInter) there is a step by step guide to see if Tkinter is working. You may go along that line. – ImportanceOfBeingErnest Dec 04 '17 at 20:21
  • @ImportanceOfBeingErnest the link for python download for my specs is right? – Code_ninja Dec 04 '17 at 20:24
  • Yes. You can run python 32 bit or python 64 bit on a 64 bit machine, that is your choice. Once you decided for a bit depth, further libraries need to stick to that. – ImportanceOfBeingErnest Dec 04 '17 at 20:26
  • @ImportanceOfBeingErnest first I downloaded the python 64 bit version and then manually installed numpy scipy matplotlib from here https://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib – Code_ninja Dec 04 '17 at 20:30
  • Forget about numpy etc. Your problem is that you don't have Tkinter. Python should have that included. As said, I would uninstall it and try again. Maybe there was a checkmark during install that you missed? – ImportanceOfBeingErnest Dec 04 '17 at 20:32
  • the download link for the python 2.7.14 64 bit for correct right/ – Code_ninja Dec 04 '17 at 20:34

0 Answers0