python导入turtle时出现错误解决办法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python导入turtle时出现错误解决办法相关的知识,希望对你有一定的参考价值。

参考技术A

λ python draw.py
Traceback (most recent call last):
File "draw.py", line 4, in <module>
turtle.width(4)
File "<string>", line 6, in width
File "C:\\Program Files\\Python37\\lib\\turtle.py", line 3812, in init
Turtle._screen = Screen()
File "C:\\Program Files\\Python37\\lib\\turtle.py", line 3662, in Screen
Turtle._screen = _Screen()
File "C:\\Program Files\\Python37\\lib\\turtle.py", line 3678, in init
_Screen._root = self._root = Root()
File "C:\\Program Files\\Python37\\lib\\turtle.py", line 434, in init
TK.Tk. init (self)
File "C:\\Program Files\\Python37\\lib\\tkinter_ init
.py", line 2023, in init
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: Can\'t find a usable tk.tcl in the following directories:
C:/Program Files/Python37/lib/tcl8.6/tk8.6 C:/Program Files/Python37/lib/tk8.6 C:/Program Files/lib/tk8.6 C:/Program Files/lib/tk8.6 C:/lib/tk8.6 C:/Program Files/library

λ python draw.py
Traceback (most recent call last):
File "draw.py", line 4, in <module>
turtle.width(4)
File "<string>", line 6, in width
File "C:\\Program Files\\Python37\\lib\\turtle.py", line 3812, in init
Turtle._screen = Screen()
File "C:\\Program Files\\Python37\\lib\\turtle.py", line 3662, in Screen
Turtle._screen = _Screen()
File "C:\\Program Files\\Python37\\lib\\turtle.py", line 3678, in init
_Screen._root = self._root = Root()
File "C:\\Program Files\\Python37\\lib\\turtle.py", line 434, in init
TK.Tk. init (self)
File "C:\\Program Files\\Python37\\lib\\tkinter_ init
.py", line 2023, in init
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: Can\'t find a usable init.tcl in the following directories:
C:\\Program Files (x86)\\CSR\\BlueSuite 2.6.9 C:/Program Files/Python37/lib/tcl8.6 C:/Program Files/lib/tcl8.6 C:/lib/tcl8.6 C:/Program Files/library C:/library C:/tcl8.6.9/library C:/tcl8.6.9/library

将tk8.6和tcl8.6复制到C:\\Program Files\\Python37\\Lib下即可解决。
具体原因未知

找到原因

eclipse导入项目时出现小红叉,但项目内容没有报其他错误。

报错信息:Description Resource Path Location Type Target runtime Apache Tomcat v8.0 is not defined. ssh Unknown Faceted Project Problem

解决办法:

1,在Eclipse工程目录下的.settings文件夹里,打开org.eclipse.wst.common.project.facet.core.xml文件,其内容是:<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="Apache Tomcat v6.0"/>
<fixed facet="jst.web"/>
<fixed facet="jst.java"/>
<installed facet="jst.java" version="5.0"/>
<installed facet="jst.web" version="2.4"/>
</faceted-project>
不要删了文件也不要全删除,要不还会有错误,删除中间几行,只留下下面三行就行
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
</faceted-project>

2,或者修改tomcat的版本也可以。













以上是关于python导入turtle时出现错误解决办法的主要内容,如果未能解决你的问题,请参考以下文章

Python包的相对导入时出现问题解决

IntelliJ IDEA 上的web项目进行数据库连接时出现java.lang.ClassNotFoundException: com.mysql.jdbc.Driver错误解决办法

导入 numpy 模块时出现 Python 错误 [重复]

为啥在导入 AudioSegment 时出现错误?

使用colab导入tensorrt时出现错误如何解决

Python:使用 pandas 导入 csv 文件时出现 ID 错误