语法错误:环境标记中不允许使用“ <”运算符

时间:2018-09-03 08:47:31

标签: python python-2.7 installation pyinstaller

在python 2.7下,我想安装模拟2.0.0,并出现以下错误:

Marker evaluation failed, see the following error.  For more information see: http://docs.openstack.org/developer/pbr/compatibility.html#evaluate-marker
ERROR:root:Error parsing
Traceback (most recent call last):
  File "/histor/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/pbr/core.py", line 96, in pbr
    attrs = util.cfg_to_args(path, dist.script_args)
  File "/histor/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/pbr/util.py", line 261, in cfg_to_args
    kwargs = setup_cfg_to_setup_kwargs(config, script_args)
  File "/histor/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/pbr/util.py", line 455, in setup_cfg_to_setup_kwargs
    if pkg_resources.evaluate_marker('(%s)' % env_marker):
  File "/histor/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1515, in evaluate_marker
    return cls.interpret(parser.expr(text).totuple(1)[1])
  File "/histor/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1549, in interpret
    return op(nodelist)
  File "/histor/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1463, in atom
    return cls.interpret(nodelist[2])
  File "/histor/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1549, in interpret
    return op(nodelist)
  File "/histor/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1484, in comparison
    raise SyntaxError(msg)
SyntaxError: '<' operator not allowed in environment markers
error in setup command: Error parsing /histor/kang/yangpc/soft/Python/Python_packages/mock-2.0.0/setup.cfg: SyntaxError: '<' operator not allowed in environment markers

经过一段时间的搜索,我得到了这个错误的提示,该错误是由较旧版本的setuptools(discussion 1discussion 2)引起的。

setup.cfg文件的内容为:

[metadata]
name = mock
summary = Rolling backport of unittest.mock for all Pythons
home-page = https://github.com/testing-cabal/mock
description-file = README.rst
author = Testing Cabal
author-email = testing-in-python@lists.idyll.org
classifier = 
        Development Status :: 5 - Production/Stable
        Environment :: Console
        Intended Audience :: Developers
        License :: OSI Approved :: BSD License
        Operating System :: OS Independent
        Programming Language :: Python
        Programming Language :: Python :: 2
        Programming Language :: Python :: 2.6
        Programming Language :: Python :: 2.7
        Programming Language :: Python :: 3
        Programming Language :: Python :: 3.2
        Programming Language :: Python :: 3.3
        Programming Language :: Python :: 3.4
        Programming Language :: Python :: 3.5
        Programming Language :: Python :: Implementation :: CPython
        Programming Language :: Python :: Implementation :: Jython
        Programming Language :: Python :: Implementation :: PyPy
        Topic :: Software Development :: Libraries
        Topic :: Software Development :: Libraries :: Python Modules
        Topic :: Software Development :: Testing
keyword = 
        testing, test, mock, mocking, unittest, patching, stubs, fakes, doubles

[extras]
test = 
        unittest2>=1.1.0
docs = 
        jinja2<2.7:python_version<"3.3" and python_version>="3"
        Pygments<2:python_version<"3.3" and python_version>="3"
        sphinx<1.3:python_version<"3.3" and python_version>="3"
        sphinx:python_version<"3" or python_version>="3.3"

[files]
packages = mock

[bdist_wheel]
universal = 1

[egg_info]
tag_build = 
tag_date = 0
tag_svn_revision = 0

但是,在测试setuptools版本15.2、27.3.0、38.0.0和最新的40.2.0之后,错误仍然存​​在。我现在不知道如何调试此问题。

所有python软件包的安装都是使用

进行的

python setup.py install --prefix=/histor/kang/yangpc/soft/Python/python2.7/

谢谢!

我尝试了以下测试

1. using pip
1.1 pip install  mock==2.0.0
/histor/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/pip-7.0.0.dev0-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Collecting mock==2.0.0
/histor/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/pip-7.0.0.dev0-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/histor/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/pip-7.0.0.dev0-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Could not find a version that satisfies the requirement mock==2.0.0 (from versions: )
  No matching distribution found for mock==2.0.0

1.2 pip install mock
/histor/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/pip-7.0.0.dev0-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Collecting mock
/histor/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/pip-7.0.0.dev0-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/histor/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/pip-7.0.0.dev0-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Could not find a version that satisfies the requirement mock (from versions: )
  No matching distribution found for mock

这调用了another question,但我还没有找到解决方法。

更新

此问题已解决,方法是将python从2.7更新到2.7.15,然后重新安装所有依赖的软件包。

谢谢大家!

1 个答案:

答案 0 :(得分:0)

我的 centos 7.9 上安装了 2 个版本的 python。 python2.7 和 `python3.6.

pip 向我抛出上述错误 pip3 确实成功了。

例如
pip install mock ## 失败

pip3 install mock ##成功