如何在python中安装turtlegraphics

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21476627/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 22:56:26  来源:igfitidea点击:

How to install turtlegraphics in python

pythonturtle-graphics

提问by user3237883

I'm trying my hands on Turtle but I can't get the module installed.

我正在尝试使用 Turtle,但无法安装该模块。

I have searched a lot and people seems to imply that it is included in the Python standard library with Tkinter but this doesn't seem to be the case for me.

我已经搜索了很多,人们似乎暗示它包含在带有 Tkinter 的 Python 标准库中,但对我来说似乎并非如此。

when I do:

当我做:

import Tkinter 

everything seems ok. But when I try

一切似乎都很好。但是当我尝试

t1 = Turtle()

I get the error

我收到错误

NameError: name 'Turtle' is not defined

As per the tutorial I'm suppose to import like this:

根据教程,我想像这样导入:

from turtlegraphics import Turtle

But no matter what I've tried I cant find how I can get the library installed.

但是无论我尝试过什么,我都找不到安装库的方法。

采纳答案by Myrkvi

You need to import it from the turtlemodule.

您需要从turtle模块中导入它。

from turtle import Turtle
t1 = Turtle()
t1.forward(100)

回答by sumanth R

Try to check within the library files whether there is a file called turtle in it . I had the same problem and i found the library file and opened it. So check it and see if it will fix your problem. Most probably turtle library file will be in Lib folder.

尝试检查库文件中是否有一个名为turtle 的文件。我遇到了同样的问题,我找到了库文件并打开了它。所以检查它,看看它是否会解决你的问题。最有可能的海龟库文件将在 Lib 文件夹中。

回答by Daniel Nilsson

Nothing here worked for me. This is what I did: I checked what configuration I had (in the upper right hand corner). I changed it so it was the python version that ran through the project and not just plain python. Then you also have to go to script path (also a setting in the configuation) and set it to the .py that you are working on :)

这里没有什么对我有用。这就是我所做的:我检查了我的配置(在右上角)。我改变了它,所以它是贯穿整个项目的 python 版本,而不仅仅是普通的 python。然后您还必须转到脚本路径(也是配置中的设置)并将其设置为您正在处理的 .py :)

回答by ASHIF-AFT

hey all of you guys just check importing that module ,you dont get any errors its already in standard libraray

嘿你们所有人只是检查导入该模块,您不会在标准库中收到任何错误