Python3安装turtle时先是出现如下报错:
C:\Users\XXX>pip install turtle
Collecting turtle
Downloading https://files.pythonhosted.org/packages/ff/f0/21a42e9e424d24bdd0e509d5ed3c7dfb8f47d962d9c044dba903b0b4a26f/turtle-0.0.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\XXX\AppData\Local\Temp\pip-install-qm1_x9jy\turtle\setup.py", line 40
except ValueError, ve:
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\XXX\AppData\Local\Temp\pip-install-qm1_x9jy\turtle\
为解决上述问题可以参考:https://blog..net/m511655654/article/details/86214086
解决掉上述问题后,当我使用pip再次直接在线安装turtle时,报错Failed building wheel for Twisted,于是我又用pip在线安装Twisted,还是报错Failed building wheel for Twisted,网上查了下资料,发现是Twisted版本的问题,Twisted的安装需要根据操作系统和python版本选择合适Twisted的版本,我用的win10 64位,python 3.6,所以选择的Twisted版本是Twisted-18.9.0-cp36-cp36m-win_amd64.whl,文件下载地址:https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted。
下载完成后使用命令pip install -e 'file_path'来安装 Twisted。我的文件路径为D:\Python\Python36\Lib\Twisted-18.9.0-cp36-cp36m-win_amd64.whl,所以完整的安装命令为:
pip install -e D:\Python\Python36\Lib\Twisted-18.9.0-cp36-cp36m-win_amd64.whl
Twisted安装完成后,就可以再次使用命令pip install turtle在线直接安装海龟包turtle。
其他参考:
https://blog..net/qq_36711420/article/details/79487772