简体   繁体   English

无法识别Python模块成员(turtle)

[英]Python module member (turtle) not recognized

I'm beginning Python, and when I started the module part of the tutorials, it looked like modules members weren't recognized. 我正在开始使用Python,当我开始教程的模块部分时,似乎模块成员未被识别。

I'm on VSCode with python extensions like "Python" and "Python for VSCode". 我在VSCode上使用python扩展,例如“ Python”和“ Python for VSCode”。 I'm on Windows. 我在Windows上。 I reinstalled Python in C:\\Python32 to add it to the path, and went into my computer > properties > advance > variable to add it to the path again. 我在C:\\ Python32中重新安装了Python以将其添加到路径,然后进入我的计算机>属性>高级>变量以再次将其添加到路径。

Example : 范例:

import os

import turtle

turtle.forward(100)

os.system("pause")

Error : Module 'turtle' has no 'forward' member 错误:模块“ turtle”没有“ forward”成员

Why aren't the module member understood by VSCode ? 为什么VSCode无法理解模块成员? I tried to run the code with IDLE, and it even stopped at the turtle import : 我试图用IDLE运行代码,它甚至在turtle导入时停止了:

import os
import turtle

Traceback (most recent call last): 追溯(最近一次通话):

File "", line 1, in 文件“”,第1行,位于

//File should have pyshell#1 in <> in "" //文件应在“>”的<>中具有pyshell#1

 import turtle 

File "C:\\Python37-32\\turtle.py", line 5, in 文件“ C:\\ Python37-32 \\ turtle.py”,第5行,在

 my_turtle = turtle.Turtle() # x is not a good name for a Turtle object 

AttributeError: module 'turtle' has no attribute 'Turtle' AttributeError:模块“ turtle”没有属性“ Turtle”

probably your file name is turtle.py , rename it and give a try . 可能您的文件名是turtle.py,将其重命名并尝试一下。

More information follow this Can't import turtle module in Python 2.x and Python 3.x 请按照以下详细信息进行操作: 无法在Python 2.x和Python 3.x中导入turtle模块

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM