turtle 安装

Python3安装turtle提示错误:Command "python setup.py egg_info" failed with error code 1

Python3.5安装turtle:

pip3 install turtle

提示错误:

Collecting turtle
  Using cached 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 "<string>", line 1, in <module>
      File "/tmp/pip-install-hpqxw6_s/turtle/setup.py", line 40
        except ValueError, ve:
                         ^
    SyntaxError: invalid syntax

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-hpqxw6_s/turtle/

网络上的方法,升级setuptools也没有用:

pip3 install --upgrade setuptools

pip在下载turtle 0.0.2包后,会解压到本地再安装,提示的错误在解压的setup.py文件里面,

解决的办法就是:https://files.pythonhosted.org/packages/ff/f0/21a42e9e424d24bdd0e509d5ed3c7dfb8f47d962d9c044dba903b0b4a26f/turtle-0.0.2.tar.gz,把turtle包下载到本地,手动解压,修改setup.py文件再安装。

  1. 打开setup.py文件,第40行修改为
     except (ValueError, ve):

    原来的是Python2的写法,没有括号,加了括号之后Python3就能用了。

  2. pip3安装修:
     pip install -e turtle-0.0.2

    -e后面接上我们修改过setup.py文件的目录。

  3. 这样就搞定了。

另外,如果提示 python-tk 未安装,用apt命令安装就可以了:

sudo apt install python-tk

猜你喜欢

转载自blog.csdn.net/liudongdong19/article/details/81283942