2

I'm having a ton of trouble installing modules. At first I thought I had messed with my python installation on mac os x but I installed a virtual machine and ubuntu 11.04 and have similar troubles. Why are both os x and ubuntu failing with the same error?

For example I can't install tkinter with it failing:

Installing collected packages: tkinter-pypy
  Running setup.py install for tkinter-pypy
    building '_tkinter' extension
    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWITH_APPINIT -I/usr/include/tcl -I/usr/include/tk -I/usr/include/python2.7 -c src/_tkinter.c -o build/temp.linux-i686-2.7/src/_tkinter.o
    src/_tkinter.c:74:17: fatal error: tcl.h: No such file or directory
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    Complete output from command /usr/bin/python -c "import setuptools;__file__='/home/pfm/build/tkinter-pypy/setup.py';execfile(__file__)" install --single-version-externally-managed --record /tmp/pip-sMB5Wi-record/install-record.txt:
    running install

running build

running build_ext

building '_tkinter' extension

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWITH_APPINIT -I/usr/include/tcl -I/usr/include/tk -I/usr/include/python2.7 -c src/_tkinter.c -o build/temp.linux-i686-2.7/src/_tkinter.o

src/_tkinter.c:74:17: fatal error: tcl.h: No such file or directory

compilation terminated.

error: command 'gcc' failed with exit status 1

----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/home/pfm/build/tkinter-pypy/setup.py';execfile(__file__)" install --single-version-externally-managed --record /tmp/pip-sMB5Wi-record/install-record.txt failed with error code 1
Storing complete log in /home/pfm/.pip/pip.log
Blender
  • 289,723
  • 53
  • 439
  • 496
PFlans
  • 410
  • 2
  • 6
  • 16
  • I thought Tkinter was a built-in package. Have you tried importing it already? – fncomp Jul 10 '11 at 23:22
  • I'm putting my comment as an answer, I checked a couple installs and it was available without any action by me. – fncomp Jul 10 '11 at 23:33
  • Missing dependencies(in /usr/lib/ or somewhere of the like). That what I could extract from error log. And TKinter is in Pythin stdlib, so you shouldn't have to install it. – nagisa Sep 03 '11 at 14:50

2 Answers2

5

I encountered exactly the same problem when trying to install tkinter-pypy on Ubuntu 11.04. The error message shows that it's looking for tcl.h file in /usr/include/tcl, but it's not there. I have to install the dev version of the tcl library (I installed tcl8.4-dev).

sudo apt-get install tcl8.4-dev

This installs the header files to /usr/include/tcl8.4. I then created a symlink /usr/include/tcl pointing to that. I also installed the dev version of the tk library (e.g. tk8.4-dev) which installed the tk.h header (needed too by tkinter-pypy) in the /usr/include/tcl directory.

After these steps, tkinter-pypy can be installed successfully.

ushadow
  • 565
  • 1
  • 6
  • 11
  • Thanks for info, let's see if I will be able to figure out how to do it in Windows (maybe edit library location in setup.py to location of tcl source I downloaded as conclusion of same struggle. I think however that your tcl (8.4) is little out of date. The source I downloaded in tcl8.5. – Tony Veijalainen Sep 16 '11 at 11:09
2

Not sure about the error, but Tkinter should be available with your Python install. Have you tried to import Tkinter. On a related note I'd definitely recommend using setuptools (aka. easy_install) or one of the other similar installation tools.

EDIT

If Tkinter is still not available, then, on Linux, try locate lib-tk and adding it to your python path

import sys; sys.path.append(PATH_TO_TK)

Then check out the Wiki to get the setup to stick: http://wiki.python.org/moin/TkInter

Another EDIT

A simple work around might be to install IDLE, which depends on Tkinter (noted by the OP).

fncomp
  • 6,040
  • 3
  • 33
  • 42
  • No luck for me with the package that came with ubuntu. Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import tkinter Traceback (most recent call last): File "", line 1, in ImportError: No module named tkinter – PFlans Jul 10 '11 at 23:45
  • 1
    @PFM case matters try `import Tkinter` – fncomp Jul 10 '11 at 23:48
  • >>> import Tkinter Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in raise ImportError, str(msg) + ', please install the python-tk package' ImportError: No module named _tkinter, please install the python-tk package – PFlans Jul 10 '11 at 23:50
  • I guess it's not there, odd. I'd `easy_install python-tk` then. – fncomp Jul 10 '11 at 23:52
  • Actually that's not working, but I see Tkinter in my package manager on Debian. – fncomp Jul 10 '11 at 23:53
  • I fixed my problem. On Ubuntu you have to install IDLE as a separate package. Once going to my package manager I realized IDLE was unchecked, thanks Josh. – PFlans Jul 11 '11 at 00:06
  • @PFM surely, I'll add that to the answer :) – fncomp Jul 11 '11 at 00:08