ImportError: no module named Tkinter (Running python with NotePad++'s NppExec)

17,335

The problem is simple -- the python command you are running does not have a module named Tkinter. The cause of the problem is more difficult to understand without more information. My first guess would be that NppExec is running a different version of python than you think it is running, and this version of python either doesn't have tkinter installed, or has it installed under a different name (python 2 is Tkinter and python 3 is tkinter).

Try using NppExec to run a script that does the following:

import sys
print sys.executable
print sys.path

The output from those commands should give you enough information to debug the problem.

Share:
17,335
Sam Westrick
Author by

Sam Westrick

Updated on June 05, 2022

Comments

  • Sam Westrick
    Sam Westrick almost 2 years

    I'm trying to run a python file using Notepad++'s NppExec plugin. My file attempts to import Tkinter using the line "from Tkinter import * ". With NppExec, I run the following script:

    python "$(FULL_CURRENT_PATH)"
    

    or sometimes

    python -i "$(FULL_CURRENT_PATH)"
    

    In either case, I get the error "ImportError: No module named Tkinter". I find this odd, because if I run my python file using any other method (IDLE, directly from command line, or even with Npp's built in Run function), I get no errors, and Tkinter imports correctly.

    I'm running Windows 7, if it makes a difference.

    Thanks in advance for your help! -Sam

  • Sam Westrick
    Sam Westrick over 12 years
    I also have Lilypond installed on my computer, which in its libraries has an older version of python. NppExec was using this version, so I just switched the command I was sending NppExec: C:\Python27\python.exe "$(FULL_CURRENT_PATH)" and now everything works great! thanks!
  • alfadog67
    alfadog67 over 10 years
    python 2 is Tkinter and python 3 is tkinter NAILED it!