没有合适的资源?快使用搜索试试~ 我知道了~
首页python安装turtle库(踩雷以及解决方法)
python安装turtle库 python中的turtle库本来是内置自带的,但是在我的憨批操作(把自己的一个文件命名为turtle.py,删除之后turtle库就不能用了)下,直接裂开。 首先安装turtle库: 直接使用pip install turtle会报错 原因是下载的turtle压缩包中的setup.py第40行报错 解决办法:根据错误信息中提供的压缩包地址将turtle包下载到本地,手动解压缩到任意目录,修改setup.py文件再运行安装。 打开setup.py,将第40行修改为:except (ValueError, ve): 原本的是python2的写法,没有括号,pyth
资源详情
资源推荐
python安装安装turtle库库(踩雷以及解决方法踩雷以及解决方法)
python安装安装turtle库库
python中的turtle库本来是内置自带的,但是在我的憨批操作(把自己的一个文件命名为turtle.py,删除之后turtle库就不能用
了)下,直接裂开。
首先安装首先安装turtle库库:
直接使用pip install turtle会报错
原因是下载的turtle压缩包中的setup.py第40行报错
解决办法解决办法:根据错误信息中提供的压缩包地址将turtle包下载到本地,手动解压缩到任意目录,修改setup.py文件再运行安装。
打开setup.py,将第40行修改为:except (ValueError, ve):
原本的是python2的写法,没有括号,python3加括号才能识别
安装:pip install -e /你解压缩后包的绝对路径/turtle 0.0.2
或者进入setup.py文件所在位置,执行下面命令:python setup.py install
但是,事情好像并没有这么简单!
打开打开pycharm之后,发现还是调用不了这个包!之后,发现还是调用不了这个包!
解决办法解决办法:打开python安装路径下的lib库,找到turtle.py文件用vim打开
我的在/usr/lib/python3.8/turtle.py
注释掉:
#__all__ = (_tg_classes + _tg_screen_functions + _tg_turtle_functions +
# _tg_utilities + ['Terminator']) # + _math_functions)
在后面追加:
__all__ = ['ScrolledCanvas', 'TurtleScreen', 'Screen', 'RawTurtle', 'Turtle', 'RawPen', 'Pen', 'Shape', 'Vec2D', 'back',
'backward', 'begin_fill', 'begin_poly', 'bk', 'addshape', 'bgcolor', 'bgpic', 'bye', 'clearscreen',
'colormode', 'delay', 'exitonclick', 'getcanvas', 'getshapes', 'listen', 'mainloop', 'mode', 'numinput',
'onkey', 'onkeypress', 'onkeyrelease', 'onscreenclick', 'ontimer', 'register_shape', 'resetscreen',
'screensize', 'setup', 'Terminator', 'setworldcoordinates', 'textinput', 'title', 'tracer', 'turtles',
'update', 'window_height', 'window_width', 'write_docstringdict', 'done', 'circle', 'clear', 'clearstamp',
'clearstamps', 'clone', 'color', 'degrees', 'distance', 'dot', 'down', 'end_fill', 'end_poly', 'fd',
'fillcolor', 'filling', 'forward', 'get_poly', 'getpen', 'getscreen', 'get_shapepoly', 'getturtle', 'goto',
'heading', 'hideturtle', 'home', 'ht', 'isdown', 'isvisible', 'left', 'lt', 'onclick', 'ondrag', 'onrelease',
'pd', 'pen', 'pencolor', 'pendown', 'pensize', 'penup', 'pos', 'position', 'pu', 'radians', 'right', 'reset',
'resizemode', 'rt', 'seth', 'setheading', 'setpos', 'setposition', 'settiltangle', 'setundobuffer', 'setx',
'sety', 'shape', 'shapesize', 'shapetransform', 'shearfactor', 'showturtle', 'speed', 'st', 'stamp', 'tilt',
'tiltangle', 'towards', 'turtlesize', 'undo', 'undobufferentries', 'up', 'width', 'write', 'xcor', 'ycor']
保存退出,重新打开pycharm,发现turtle库已经可以正常使用了!
ps:一定不要把文件名命名为和库一样的啊!血的教训:一定不要把文件名命名为和库一样的啊!血的教训!
作者:iron_Le
weixin_38733367
- 粉丝: 3
- 资源: 907
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- zigbee-cluster-library-specification
- JSBSim Reference Manual
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功