Python 3.4 在 ubuntu 14.04 上 setup.py 中的语法无效,为什么?

Python 3.4 invalid syntax in setup.py on ubuntu 14.04, why?

我的 python 项目 rma 中有一个错误 (ussue #14 on github)。使用 python 3.4 安装它 trow pip 1.5.4 有些错误是这样的:

Downloading/unpacking rma
Downloading rma-0.1.5.tar.gz
Running setup.py (path:/tmp/pip_build_root/rma/setup.py) egg_info for package rma
Traceback (most recent call last):
  File "<string>", line 17, in <module>
  File "/tmp/pip_build_root/rma/setup.py", line 47
    setup(**sdict, install_requires=['redis', 'tabulate', 'tqdm', 'msgpack-python'])
                 ^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "<string>", line 17, in <module>

File "/tmp/pip_build_root/rma/setup.py", line 47

setup(**sdict, install_requires=['redis', 'tabulate', 'tqdm', 'msgpack-python'])

             ^

SyntaxError: invalid syntax

----------------------------------------

我自己的pip版本是8.0.2(python是3.5)。

我在 python 新来的,抱歉,如果这个众所周知的问题。我想知道 - 我应该找到修复它的方法(如果这是我的问题)还是建议我的用户更新 pip?

该软件包不会安装在任何 Python 版本 < 3.5 上,因为语法确实在 Python 3.5 和更新版本以外的任何版本上都无效。

您不能将 **kwargs 语法放在其他关键字参数的前面。两者应该交换:

setup(install_requires=['redis', 'tabulate', 'tqdm', 'msgpack-python'], **sdict)

将此作为错误报告是正确的做法;该软件包声明它支持 Python 3.4 及更高版本。

Python 3.5 通过 PEP 448 添加了对任意数量的 *args**kwargs 扩展的支持,为上述工作打开了大门。