【问题标题】:Cannot get python Turtle to work in Pydev on linux [duplicate]无法让 python Turtle 在 Linux 上的 Pydev 中工作 [重复]
【发布时间】:2013-01-11 20:11:14
【问题描述】:

可能重复:
Tkinter: “Python may not be configured for Tk”

我正在运行 Fedora 17 并安装了 Eclipse。我正在尝试通过导入海龟来执行使用 python Turtle 的作业。每当我使用海龟方法时,我都会收到危险信号,例如 turtle.forward(100)

我收到此错误:

Traceback (most recent call last):
  File "/home/g2n/Desktop/school/college/cs/240/src/cw1/faces.py", line 6, in <module>
    import turtle
  File "/usr/local/lib/python3.3/turtle.py", line 107, in <module>
    import tkinter as TK
  File "/usr/local/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'

我的pydev 路径是/usr/local/bin/python3.3

有人帮忙吗?!

【问题讨论】:

  • 为什么不用系统python(/usr/bin/python3)?

标签: python eclipse tkinter pydev turtle-graphics


【解决方案1】:

就像其他链接所说的那样,确保在尝试在 python 中导入模块之前安装tk-dev;我也会在 Python 2.7 解释器上对此进行测试,3.3 太新了,Tkinter 可能不完全受支持或没有经过很好的测试。因此,如果允许,请尝试 2​​.7。

确保您正确导入它:import Tkinter

这里是如何安装Tkinter http://tkinter.unpythonic.net/wiki/How_to_install_Tkinter

这里有一个链接可以为您提供一些 Tkinter 的 RPM: http://rpmfind.net/linux/rpm2html/search.php?query=tk-devel

【讨论】:

  • tk-dev 不需要使用 tkinter。只需要构建另一个支持 tkinter 的 python。而且 python3.3 并不是那么新,并且可以在最近的发行版上完美运行(并且经过测试)。
  • 我为 tk-dev 进行了安装,但没有成功。导入 tkinter 也不起作用。
【解决方案2】:
  1. 检查依赖项和所有需要的库 - Think Python 清楚地说明了这一点。
  2. 尽量不要使用python3.3,而是使用更早的python 2.7版本
  3. 为什么需要 Eclipse?您正在运行什么操作系统?

【讨论】:

  • #3 ,OP 在 Fedora 17 上声明了他,但没有说是哪个拱门; 32/64 位?
  • 我的错(操作系统...)。我认为2.7会解决他的问题。
  • 3.3和2.7有什么区别?
猜你喜欢
  • 1970-01-01
  • 2018-05-11
  • 2012-06-15
  • 1970-01-01
  • 2013-08-17
  • 2019-01-12
  • 2017-07-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多