1

I'm python2.7 64bits on a 64-bits os, and installed matplotlib 64 (matplotlib-1.5.1-cp27-none-win_amd64.whl), but have this import error:

Traceback (most recent call last):
  File "sim.py", line 6, in <module>
    from Solution import *
  File "C:\Python27\My sim\Solution.py", line 6, in <module>
    import matplotlib.pyplot as plt
  File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 114, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "C:\Python27\lib\site-packages\matplotlib\backends\__init__.py", line 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "C:\Python27\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 6, in <module>
    from matplotlib.externals.six.moves import tkinter as Tk
  File "C:\Python27\lib\site-packages\matplotlib\externals\six.py", line 199, in load_module
    mod = mod._resolve()
  File "C:\Python27\lib\site-packages\matplotlib\externals\six.py", line 113, in _resolve
    return _import_module(self.mod)
  File "C:\Python27\lib\site-packages\matplotlib\externals\six.py", line 80, in _import_module
    __import__(name)
  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 nÆest pas une application Win32 valide.

Any idea?

Betty
  • 237
  • 6
  • 16
  • Does the error reproduce if you try a simple statement: `import tkinter` ? – CristiFati Feb 11 '16 at 17:53
  • @CristiFati: this is what i got when trying `import tkinter`: `Traceback (most recent call last): File "", line 1, in ImportError: No module named tkinter` – Betty Feb 11 '16 at 18:36
  • Yes, my bad I forgot an underscore: `import _tkinter`. _\_tkinter_ is a dynamic (_.pyd_) module (written in C). It's actually a _.dll_, and it has other dlls as dependencies. This kind of error usually appears when some of those dependencies are found (in terms of file name) but they don't have the right content (might be another version of that dll, or another architecture). – CristiFati Feb 11 '16 at 18:52
  • Even with `import _tkinter` I got the error message `File "", line 1, in ImportError: DLL load failed: %1 nÆest pas une application Win32 valide.` i.e `ImportError: DLL load failed: %1 is not a valid Win32 application`. I think i must configure python for tk, but don't know how to do! – Betty Feb 11 '16 at 19:07
  • hmm, official Python comes with all the required stuff for _tk_ (a bunch of _\*tk\*.pyd/dll_ and _\*tcl\*.dll_ located in the _DLLs_ folder of your Python HOME dir). – CristiFati Feb 12 '16 at 08:25
  • I checked my DLLs Python home directory, and it contains: __tkinter.pyd_ , _tcl85.dll_ , _tclpip85.dll_ and _tk85.dll_ . That should be ok for `tkinter` to work... – Betty Feb 12 '16 at 11:28
  • Yes indeed. Do you have an official Python distribution? Or is custom built on your machine. Just to test whether this is _\_tkinter_ specific, could you also try importing other dynamic modules (`import _ssl`, `import _msi`, `import _socket`). I'm trying to figure out which dll is causing problems. Unfortunately, Python2.7 is built using VStudio 2k8, which still uses the concept of assemblies. – CristiFati Feb 12 '16 at 12:24
  • I have installed Python using _python-2.7.10.msi_ file downloded from [link](http://python.org). Importing listed dynamic modules is fine. – Betty Feb 12 '16 at 13:09

1 Answers1

1

Had the same problem. Uninstalled python and related modules completely; deleted C:\Python27 and reinstalled afresh. Works again. I think the issue was conflict between old versions.

casper.dcl
  • 13,035
  • 4
  • 31
  • 32
  • I think it would be the solution to this problem. I have no more access to this machine and when I tried to deinstall python, I was blocked by administrator machine rights. – Betty Mar 09 '16 at 10:33