解决python3安装turtle时出错:except ValueError, ve: SyntaxError: invalid syntax python setup.py egg_info ...

在windows10下使用python -m pip install turtle安装turtle报错,提示错误信息如下:

C:\windows\system32>python -m pip install turtle
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting turtle
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ff/f0/21a42e9e424d24bdd0e509d5ed3c7dfb8f47d962d9c044dba903b0b4a26f/turtle-0.0.2.tar.gz
    ERROR: Command errored out with exit status 1:
     command: 'C:\Program Files\Python37\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-_424ow1w\\turtle\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-_424ow1w\\turtle\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: C:\Users\user\AppData\Local\Temp\pip-install-_424ow1w\turtle\
    Complete output (6 lines):
    Traceback (most recent call last):
      File "", line 1, in 
      File "C:\Users\user\AppData\Local\Temp\pip-install-_424ow1w\turtle\setup.py", line 40
        except ValueError, ve:
                         ^
    SyntaxError: invalid syntax
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

解决方法:

去https://pypi.org/project/turtle/0.0.2/#files下载turtle-0.0.2.tar.gz

解压之后使用pip install -e ./turtle-0.0.2命令进行安装,正确安装后提示如下:

C:\Users\user\Desktop\turtle-0.0.2>pip install -e ./turtle-0.0.2
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Obtaining file:///C:/Users/user/Desktop/turtle-0.0.2/turtle-0.0.2
Requirement already satisfied: Twisted>=8.0.1 in c:\program files\python37\lib\site-packages (from turtle==0.0.2) (19.7.0)
Collecting PyYAML>=3.0.8 (from turtle==0.0.2)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/bc/3f/4f733cd0b1b675f34beb290d465a65e0f06b492c00b111d1b75125062de1/PyYAML-5.1.2-cp37-cp37m-win_amd64.whl (215kB)
     |████████████████████████████████| 225kB 939kB/s
Requirement already satisfied: incremental>=16.10.1 in c:\program files\python37\lib\site-packages (from Twisted>=8.0.1->turtle==0.0.2) (17.5.0)
Requirement already satisfied: PyHamcrest>=1.9.0 in c:\program files\python37\lib\site-packages (from Twisted>=8.0.1->turtle==0.0.2) (1.9.0)
Requirement already satisfied: attrs>=17.4.0 in c:\program files\python37\lib\site-packages (from Twisted>=8.0.1->turtle==0.0.2) (19.1.0)
Requirement already satisfied: constantly>=15.1 in c:\program files\python37\lib\site-packages (from Twisted>=8.0.1->turtle==0.0.2) (15.1.0)
Requirement already satisfied: Automat>=0.3.0 in c:\program files\python37\lib\site-packages (from Twisted>=8.0.1->turtle==0.0.2) (0.7.0)
Requirement already satisfied: hyperlink>=17.1.1 in c:\program files\python37\lib\site-packages (from Twisted>=8.0.1->turtle==0.0.2) (19.0.0)
Requirement already satisfied: zope.interface>=4.4.2 in c:\program files\python37\lib\site-packages (from Twisted>=8.0.1->turtle==0.0.2) (4.6.0)
Requirement already satisfied: six in c:\program files\python37\lib\site-packages (from PyHamcrest>=1.9.0->Twisted>=8.0.1->turtle==0.0.2) (1.12.0)
Requirement already satisfied: setuptools in c:\program files\python37\lib\site-packages (from PyHamcrest>=1.9.0->Twisted>=8.0.1->turtle==0.0.2) (41.2.0)
Requirement already satisfied: idna>=2.5 in c:\program files\python37\lib\site-packages (from hyperlink>=17.1.1->Twisted>=8.0.1->turtle==0.0.2) (2.8)
Installing collected packages: PyYAML, turtle
  Running setup.py develop for turtle
Successfully installed PyYAML-5.1.2 turtle

你可能感兴趣的:(解决python3安装turtle时出错:except ValueError, ve: SyntaxError: invalid syntax python setup.py egg_info ...)