Python模块安装问题

PFl*_*ans 2 python tkinter

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

例如,我无法安装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
Run Code Online (Sandbox Code Playgroud)

ush*_*dow 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.我还安装了tk库的dev版本(例如tk8.4-dev),它在/ usr/include/tcl目录中安装了tk.h头文件(tkinter-pypy也需要).

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