Python3安装turtle模块遇到的问题AttributeError:module 'turtle' has no attribute 'setup'

1、安装turtle模块

在命令模式下:pip3 install turtle

出现如下错误:

Python3安装turtle模块遇到的问题AttributeError:module 'turtle' has no attribute 'setup'

解决:按照下面步骤4)修改代码即可

2.运行PythonDraw.py文件时报错(文件名没有和关键字重复):

Python3安装turtle模块遇到的问题AttributeError:module 'turtle' has no attribute 'setup'

解决:

1)先升级setuptools工具

在命令模式下:pip3 install --upgrade setuptools

若权限不够, sudo su 然后输入密码,再次升级

2)下载turtle 0.0.2包:下载地址:https://files.pythonhosted.org/packages/ff/f0/21a42e9e424d24bdd0e509d5ed3c7dfb8f47d962d9c044dba903b0b4a26f/turtle-0.0.2.tar.gz

3)将压缩包放到本地文件夹中解压:

Python3安装turtle模块遇到的问题AttributeError:module 'turtle' has no attribute 'setup'

4)打开setup.py文件,将第四十行代码修改为(加上括号,因为python版本问题):

Python3安装turtle模块遇到的问题AttributeError:module 'turtle' has no attribute 'setup'

5)使用pip安装,找到setup.py文件,邮件单击->属性,复制它的路径:

Python3安装turtle模块遇到的问题AttributeError:module 'turtle' has no attribute 'setup'

在命令模式下:pip install -e 路径,例:我的路径为:

pip install -e /home/krystal/下载/turtle-0.0.2