Tkinter module not found

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shuaib

    Tkinter module not found

    Hey,

    Even though I freshly installed Tcl and Tk, python still seem to have
    problems accessing Tkinter module. Here is what says when I do "import
    Tkinter"

    ==
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    ImportError: No module named Tkinter
    ==

    Any ideas how to fix this problem? (Gentoo distribution)

    Thanks.

  • John Salerno

    #2
    Re: Tkinter module not found

    Shuaib wrote:
    Hey,
    >
    Even though I freshly installed Tcl and Tk, python still seem to have
    problems accessing Tkinter module. Here is what says when I do "import
    Tkinter"
    >
    ==
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    ImportError: No module named Tkinter
    ==
    >
    Any ideas how to fix this problem? (Gentoo distribution)
    >
    Thanks.
    >
    The cause of this is usually that you are using a different version of
    Python than the one you installed Tkinter into, but being a Linux newbie
    I have yet to discover how to redirect the 'python' command to invoke
    the newer version of Python.

    Comment

    • Tim Chase

      #3
      Re: Tkinter module not found

      The cause of this is usually that you are using a different
      version of Python than the one you installed Tkinter into, but
      being a Linux newbie I have yet to discover how to redirect
      the 'python' command to invoke the newer version of Python.

      The OS looks for the first 'python' it finds in its path.

      In Linux (or other *nix OSes), you can use

      bashwhich python

      and it will reply with which python it's pointing to. You can
      then change into that directory (usually "/usr/bin") and get back
      a listing of various pythons. On my Debian linux distro at home,
      I get something back that looks like

      bashwhich python
      /usr/bin/python
      bashcd /usr/bin
      bashls -lsF python* | grep -o "python.*"
      python -python2.3*
      python2.3*
      python2.4*

      You *should* be able to just relink the "python" link to the new
      version of python:

      bashln -sf /usr/bin/python2.4 /usr/bin/python

      I don't know if this will cause other problems down the line for
      packages that expect the system default.

      Alternatively, at least on my system, you can force your choice
      by explicity running "python2.3" or "python2.4" instead of just
      "python".

      You can determine your path via

      bashecho $PATH

      along which your shell will search for an executable.

      Win32 has a similar executable search path

      c:\echo %PATH%

      but doesn't have something as handy as the "which" command to do
      the hunting for you.

      HTH,

      -tkc






      Comment

      • John Salerno

        #4
        Re: Tkinter module not found

        Tim Chase wrote:
        >The cause of this is usually that you are using a different
        >version of Python than the one you installed Tkinter into, but
        >being a Linux newbie I have yet to discover how to redirect
        >the 'python' command to invoke the newer version of Python.
        >
        >
        The OS looks for the first 'python' it finds in its path.
        >
        In Linux (or other *nix OSes), you can use
        >
        bashwhich python
        A very helpful command to know! I'll have to wait til I get home to play
        on Linux though. Then I can try these things you suggested.

        I'm suddenly very bored here at work using Windows. :)

        Comment

        • Shuaib

          #5
          Re: Tkinter module not found

          Hey again,

          I am using the latest python available on my system (2.4). So I don't
          think that's the problem.

          Any more ideas? Do I need to install Tkinter as a seperate
          module/package? As I said, I've already installed Tcl/Tk, though.

          Thanks for your time.


          Tim Chase wrote:
          The cause of this is usually that you are using a different
          version of Python than the one you installed Tkinter into, but
          being a Linux newbie I have yet to discover how to redirect
          the 'python' command to invoke the newer version of Python.
          >
          >
          The OS looks for the first 'python' it finds in its path.
          >
          In Linux (or other *nix OSes), you can use
          >
          bashwhich python
          >
          and it will reply with which python it's pointing to. You can
          then change into that directory (usually "/usr/bin") and get back
          a listing of various pythons. On my Debian linux distro at home,
          I get something back that looks like
          >
          bashwhich python
          /usr/bin/python
          bashcd /usr/bin
          bashls -lsF python* | grep -o "python.*"
          python -python2.3*
          python2.3*
          python2.4*
          >
          You *should* be able to just relink the "python" link to the new
          version of python:
          >
          bashln -sf /usr/bin/python2.4 /usr/bin/python
          >
          I don't know if this will cause other problems down the line for
          packages that expect the system default.
          >
          Alternatively, at least on my system, you can force your choice
          by explicity running "python2.3" or "python2.4" instead of just
          "python".
          >
          You can determine your path via
          >
          bashecho $PATH
          >
          along which your shell will search for an executable.
          >
          Win32 has a similar executable search path
          >
          c:\echo %PATH%
          >
          but doesn't have something as handy as the "which" command to do
          the hunting for you.
          >
          HTH,
          >
          -tkc

          Comment

          • John Salerno

            #6
            Re: Tkinter module not found

            Shuaib wrote:
            Hey again,
            >
            I am using the latest python available on my system (2.4). So I don't
            think that's the problem.
            >
            Any more ideas? Do I need to install Tkinter as a seperate
            module/package? As I said, I've already installed Tcl/Tk, though.
            Hmm, yes, I think tkinter is separate from Tk, so you might try doing a
            search for it in your repositories and see if something comes up that
            you don't have installed yet.

            Comment

            • Thomas Heller

              #7
              Re: Tkinter module not found

              John Salerno schrieb:
              Tim Chase wrote:
              >>The cause of this is usually that you are using a different
              >>version of Python than the one you installed Tkinter into, but
              >>being a Linux newbie I have yet to discover how to redirect
              >>the 'python' command to invoke the newer version of Python.
              >>
              >>
              >The OS looks for the first 'python' it finds in its path.
              >>
              >In Linux (or other *nix OSes), you can use
              >>
              > bashwhich python
              >
              A very helpful command to know! I'll have to wait til I get home to play
              on Linux though. Then I can try these things you suggested.
              >
              I'm suddenly very bored here at work using Windows. :)
              Well, we have python, haven't we?


              Microsoft Windows XP [Version 5.1.2600]
              (C) Copyright 1985-2001 Microsoft Corp.

              c:\>which python
              c:\util\python. EXE

              c:\>which which
              c:\util\which.P Y

              c:\>type \util\which.py
              import os, string, sys
              PATH = os.environ["PATH"]
              PATHEXT = os.environ["PATHEXT"]

              all = 0
              if sys.argv[1] == "-a":
              del sys.argv[1]
              all = 1

              arg = sys.argv[1]

              base, ext = os.path.splitex t (arg)
              for path in string.split (PATH, ';'):
              if not ext:
              for extension in string.split(PA THEXT, ';'):
              if os.path.isfile( path + '\\' + arg + extension):
              print path + '\\' + arg + extension
              if not all:
              sys.exit (0)
              else:
              if os.path.isfile (path + '\\' + arg):
              print path + '\\' + arg
              if not all:
              sys.exit (0)

              c:\>


              There may be better variants of which out there...

              Thomas

              Comment

              • John Salerno

                #8
                Re: Tkinter module not found

                Thomas Heller wrote:
                c:\>which python
                c:\util\python. EXE
                which didn't work for me on the command prompt...is it native to it?

                Comment

                • Dan

                  #9
                  Re: Tkinter module not found

                  Shuaib wrote:
                  Hey again,
                  >
                  I am using the latest python available on my system (2.4). So I don't
                  think that's the problem.
                  >
                  Any more ideas? Do I need to install Tkinter as a seperate
                  module/package? As I said, I've already installed Tcl/Tk, though.
                  This is a wild guess, but I just installed Python 2.5b3 from source to
                  play with it, and on the first attempt I didn't get Tkinter. Turns out
                  I was missing tcl.h and tk.h in /usr/include. On my system (Fedora), I
                  had to install tcl-devel and tk-devel to get those header files.

                  Since you mentioned Gentoo, which builds from source, maybe you have a
                  similar issue. Although you'd think there'd be some dependency checking
                  in your package system that would catch it. Like I said, this is just
                  a wild guess.

                  /Dan

                  --
                  dedded att verizon dott net

                  Comment

                  • Shuaib

                    #10
                    Re: Tkinter module not found

                    Well, I finally solved my problem. I just had to reinstall python with
                    the USE flags of tcl and tk.

                    #USE="tcl tk" emerge python

                    And now I can use Tkinter

                    Thanks guys!

                    Comment

                    • Philippe Martin

                      #11
                      Re: Tkinter module not found

                      Shuaib wrote:
                      Hey,
                      >
                      Even though I freshly installed Tcl and Tk, python still seem to have
                      problems accessing Tkinter module. Here is what says when I do "import
                      Tkinter"
                      >
                      ==
                      Traceback (most recent call last):
                      File "<stdin>", line 1, in ?
                      ImportError: No module named Tkinter
                      ==
                      >
                      Any ideas how to fix this problem? (Gentoo distribution)
                      >
                      Thanks.
                      That happened once to me when I compiled python without tcl/tk installed
                      (prior to compiling)


                      Comment

                      Working...