2011-07-10 251 views
2

我在安装模块时遇到了很多麻烦。起初我以为我在mac os x上搞砸了我的python安装,但是我安装了一个虚拟机和ubuntu 11.04,并且有类似的麻烦。为什么os x和ubuntu都出现同样的错误?Python模块安装问题

例如我不能用它未能安装Tkinter的:

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 
+0

我以为Tkinter是一个内置的软件包。你有没有试过导入它? – fncomp

+0

我很确定它也是。 – Blender

+0

我把我的评论作为答案,我检查了几次安装,并且它没有任何行动可用。 – fncomp

回答

2

不知道的错误,但Tkinter的应该是可用你的Python安装。你有没有试过import Tkinter。在相关说明中,我肯定会推荐使用setuptools(aka。easy_install)或其他类似的安装工具之一。

编辑

如果Tkinter的是还没有上市,那么,在Linux上,尝试locate lib-tk并将其添加到你的Python路径

import sys; sys.path.append(PATH_TO_TK)

然后检查了维基来获取设置坚持:http://wiki.python.org/moin/TkInter

另一编辑

一个简单的解决方法可能是安装IDLE,这取决于Tkinter(由OP指出)。

+0

与Ubuntu一起提供的软件包对我来说并不算什么。 Python 2.7.1+(r271:86832,2011年4月11日,18:05:24) [GCC 4.5.2] on linux2 输入“help”,“copyright”,“credits”或“license”信息。 >>>进口Tkinter的 回溯(最近通话最后一个): 文件 “”,1号线,在 导入错误:没有模块名为Tkinter的 – PFlans

+1

@PFM情况下,重要的尝试'进口Tkinter' – fncomp

+0

>>>进口Tkinter的 回溯(最近呼叫最后): 文件“”,第1行,在 文件“/usr/lib/python2.7/lib-tk/Tkinter。py“,第42行,在 raise ImportError,str(msg)+',请安装python-tk软件包' ImportError:没有名为_tkinter的模块,请安装python-tk软件包 – PFlans

5

我在尝试在Ubuntu 11.04上安装tkinter-pypy时遇到了完全相同的问题。错误消息显示它正在/ usr/include/tcl中查找tcl.h文件,但它不在那里。我必须安装tcl库的开发版本(我安装了tcl8.4-dev)。

sudo apt-get install tcl8.4-dev

这将安装头文件/usr/include/tcl8.4。然后我创建了一个符号链接/ usr/include/tcl指向它。我还在/ usr/include/tcl目录中安装了tk库的开发版本(例如tk8.4-dev),它安装了tk.h头文件(tkinter-pypy也需要)。

完成这些步骤后,可以成功安装tkinter-pypy。

+0

感谢您的信息,让我们来看看我是否能够弄清楚如何在Windows中做到这一点(也许编辑setup.py中的库位置到tcl源文件的位置我下载的结果是相同的,但我认为你的tcl(8.4)很少出于da TE。我在tcl8.5下载的源代码。 –