我在服务器上使用linux.我没有root权限.我在本地安装了python-3.2.3到“/ home / sam / install_sam”.当我导入tkinter模块.我收到以下错误:
ImportError: No module named _tkinter, please install the python-tk package
我知道我需要安装Tkinter模块.因为我没有root权限.我不能像下面的命令一样使用:
apt-get install python-tk
sudo apt-get install python-tk
我在goolge上搜索.我从here获得tcl / tk.我使用以下命令安装它们.
cd ~/Downloads/tcl8.5.11/unix
./configure --prefix=/home/sam/install_sam/tcl
make
make install
cd ~/Downloads/tk8.5.11/unix
./configure --prefix=/home/sam/install_sam/tk
--with- tcl=/home/sam/Downloads/tcl8.5.11/unix
make
make install
cd ~/Downloads/Python3.2.3/
export LD_LIBRARY_PATH=/home/sam/install_sam/tcl/lib:/home/sam/install_sam/tk/lib
export LD_RUN_PATH=/home/sam/install_sam/tcl/lib:/home/sam/install_sam/tk/lib
./configure --prefix=/home/sam/install_sam/python
make
make install
我仍然有错误:INFO:找不到Tcl / Tk库和/或标题.我应该如何为python配置tcl / tk
解决方法:
在构建Python 3之前,使用CPPFLAGS环境变量来设置tcl和tk的include目录.这对我有用.
export CPPFLAGS="-I/home/sam/install_sam/tcl/include -I/home/sam/install_sam/tk/include"