[英]Python not configured for Tk
I am using Ubuntu 13.10 and Python 3.3.4 using pyenv .我使用pyenv使用 Ubuntu 13.10 和 Python 3.3.4。 I have no problem using other modules.
我使用其他模块没有问题。 When I enter python console and write
当我进入 python 控制台并写入时
import tkinter
It outputs它输出
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/serdar/.pyenv/versions/3.3.4/lib/python3.3/tkinter/__init__.py", line 40, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named '_tkinter'
I already installed python3-tk
and tk-devel
.我已经安装了
python3-tk
和tk-devel
。
You need to have the Tk development files/headers available during pyenv install
.您需要在
pyenv install
期间提供 Tk 开发文件/头文件。
On Ubuntu (15.04) the following should provide them: sudo apt-get install tk-dev
.在 Ubuntu (15.04) 上,以下内容应提供它们:
sudo apt-get install tk-dev
。
After this, pyenv install 3.4.3
(or pyenv install 2.7.10
etc) should pick it up and have support for Tk.在此之后,
pyenv install 3.4.3
(或pyenv install 2.7.10
等)应该选择它并支持 Tk。
This is a guide for Mac users,这是 Mac 用户的指南,
pyenv uninstall 3.7.2
pyenv uninstall 3.7.2
brew install tcl-tk
brew install tcl-tk
export LDFLAGS="-L/usr/local/opt/tcl-tk/lib"
export CPPFLAGS="-I/usr/local/opt/tcl-tk/include"
export PATH=$PATH:/usr/local/opt/tcl-tk/bin
pyenv install 3.7.2
pyenv install 3.7.2
The TK should work now TK现在应该可以工作了
For Mac users,对于 Mac 用户,
brew uninstall pyenv && rm -rf ~/.pyenv
.brew uninstall pyenv && rm -rf ~/.pyenv
。brew update
brew install zlib
brew install tcl-tk #otherwise we may have problems with tf package
brew install pyenv
# For compilers to find zlib you may need to set:
export LDFLAGS="${LDFLAGS} -L/usr/local/opt/zlib/lib"
export CPPFLAGS="${CPPFLAGS} -I/usr/local/opt/zlib/include"
# For pkg-config to find zlib you may need to set:
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH} /usr/local/opt/zlib/lib/pkgconfig"
Then you are set up!.然后你就设置好了!。 For more details check this github gist.
有关更多详细信息,请查看此github gist。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.