user1798774
user1798774

Reputation: 1

Spyder won't run Installed Modules - Windows 10

I am trying to use tkinter in Spyder and I got the error:

Traceback (most recent call last):

  File "<ipython-input-2-29b37e014535>", line 1, in <module>
    import tkinter

  File "C:\Program Files\Spyder\pkgs\tkinter\__init__.py", line 36, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk

ImportError: DLL load failed: The specified module could not be found.

I thought that meant that the module was not installed but I decided to look in Spyder/pkgs before going through the hassle of installing it. tkinter is in that folder, which means it should have been installed with Spyder but I can't get Spyder to recognize the module. What is going on?

Upvotes: 0

Views: 325

Answers (2)

Carlos Cordoba
Carlos Cordoba

Reputation: 34186

(Spyder maintainer here) This is an issue with our Windows installer (unfortunately, we incorrectly packaged Tkinter on it and we didn't notice it).

We plan to fix it in our 4.2.2 version, to be released in mid February.

Upvotes: 2

Anon7250
Anon7250

Reputation: 148

The error message on the last line says "DLL load failed", which means that the error is more fundamental than a problem with Python scripts. DLLs are dynamically linked libraries used only in Windows, usually created from a compiler language like C or C++.

So, it means that you did install tkinter package in Python, but probably didn't install the correct version for your Windows.

tkinter is in that folder

For modules that contain DLLs or C/C++ code, they cannot be installed by directly copying the source code.

Please delete that folder your own installation. (If you installed that Spyder/pkgs/tkinter folder, then delete that folder. If you installed tkinter through pip, then undo it.) Then, try running the program without installing tkinter yourself. Sometimes, the Python installation already includes its own tkinter.

Now, regarding how to install tkinter properly. It depends on which Python you are using.

  • If you installed Python from python.org, then tkinter is included. As long as you didn't override that installation, it should be usable.
  • If you installed Python through Conda, then you should use conda command to install tkinter, instead of pip.
  • If you installed Python through cygwin, MinGW, or similar environments, you'd need to download tkinter through their installers.
  • If this "Spyder" program comes with its own Python.exe, then use that Python instead of your own. It will probably load that Spyder/pkgs/tkinter package. And if this fails, then the Spyder program itself is to blame: It didn't ship the correct DLLs. You should try downloading a newer version of Spyder.

Upvotes: -1

Related Questions