简体   繁体   English

Python - 格式的零长度字段名称

[英]Python - Zero length field name in format

I'm using Python on my Centos machine and when I try to run my program I have this error displayed : 我在我的Centos机器上使用Python,当我尝试运行我的程序时,我显示了以下错误:

Running setup.py egg_info for package pyepr
Traceback (most recent call last):
  File "<string>", line 16, in <module>
  File "/tmp/pip-build-root/pyepr/setup.py", line 68, in <module>
    print('using EPR C API sources at "{}"'.format(eprsrcdir))
ValueError: zero length field name in format
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

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

  File "/tmp/pip-build-root/pyepr/setup.py", line 68, in <module>

print('using EPR C API sources at "{}"'.format(eprsrcdir))

ValueError: zero length field name in format

I have already checked the other questions about this subject and I already installed Python 2.7.6 and set it as my default configuration as shown below.... 我已经检查了关于这个主题的其他问题,我已经安装了Python 2.7.6并将其设置为我的默认配置,如下所示....

 $ python -V
 Python 2.7.6

Something must have gone wrong, but I don't know what. 肯定有什么问题,但我不知道是什么。

Anybody has an idea? 有人有想法吗?

Thanks 谢谢

That error can only be raised if you run that code with Python 2.6 or older. 如果您使用Python 2.6或更早版本运行该代码,则只能引发该错误。 In those versions, you must explicitly number the format fields for str.format (starting at 0 ): 在这些版本中,您必须显式编号为str.format的格式字段(从0开始):

print('using EPR C API sources at "{0}"'.format(eprsrcdir))

Of course, this is only a temporary fix. 当然,这只是一个临时修复。 It would be better to investigate why your code is not being run with Python 2.7 in the first place and then fix that instead. 最好先调查一下为什么你的代码没有用Python 2.7运行然后修复它。

If you run an install using sudo, you are going to end up using the sudo path's Python interpreter. 如果使用sudo运行安装,那么最终将使用sudo路径的Python解释器。 Not sure if you are using sudo or not for installing, but there is a good chance you are. 不确定您是否使用sudo进行安装,但您很有可能。

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

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