简体   繁体   English

在 linux 终端中安装 package 时遇到语法错误

[英]Syntax Error encountered while installing package in linux terminal

I'm trying to download the Turtle Graphics Package for Python, so I enter the following command into my linux terminal:我正在尝试为 Python 下载 Turtle Graphics Package,因此我在 linux 终端中输入以下命令:

myusername@penguin:~/Pys$ pip3 install turtle

And here's the error I encountered:这是我遇到的错误:

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-build-c6dr99ga/turtle/setup.py", line 40
        except ValueError, ve:
                         ^
    SyntaxError: invalid syntax

It seems like there's an syntax error in the file I was trying to download.我尝试下载的文件中似乎存在语法错误。 Is there a way I can fix that?有没有办法解决这个问题?

Turtle graphics is already part of Python standard library, you don't need to install it.海龟图形已经是 Python 标准库的一部分,你不需要安装它。

See: https://docs.python.org/3/library/turtle.html参见: https://docs.python.org/3/library/turtle.html

Just import it:只需导入它:

import turtle

There seems to be an issue with how the setup.py has been written. setup.py 的编写方式似乎存在问题。

To fix this, run要解决此问题,请运行

pip3 install turtle

Your output will contain a link to the turtle tar.gz file ( https://files.pythonhosted.org/packages/ff/f0/21a42e9e424d24bdd0e509d5ed3c7dfb8f47d962d9c044dba903b0b4a26f/turtle-0.0.2.tar.gz ) Your output will contain a link to the turtle tar.gz file ( https://files.pythonhosted.org/packages/ff/f0/21a42e9e424d24bdd0e509d5ed3c7dfb8f47d962d9c044dba903b0b4a26f/turtle-0.0.2.tar.gz )

run wget <paste_link_here> or manually download the tar.gz file from the link运行wget <paste_link_here>或从链接手动下载 tar.gz 文件

extract the folder using tar -xvf turtle-0.0.2.tar.gz使用tar -xvf turtle-0.0.2.tar.gz提取文件夹

go into the turtle directory and open setup.py in any text editor. go 进入海龟目录并在任何文本编辑器中打开 setup.py。

At line 40, change在第 40 行,更改

`except ValueError, ve:`

to

except ValueError as ve:

then compress it the folder to a tar file again and then run pip3 install on the local file然后再次将文件夹压缩为 tar 文件,然后在本地文件上运行 pip3 install

pip3 install turtle-0.0.2.tar.xz 

This should fix the problems with the package这应该可以解决 package 的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM