1

Under python 2.7, I want to install mock-2.0.0, and got the following error:

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

After a while googling, I got the hints that this error was produced by older version of setuptools (discussion 1 and discussion 2).

The content of setup.cfg file is:

[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

However, After testing setuptools version 15.2, 27.3.0, 38.0.0 and the latest 40.2.0, the error remain. I have no idea how to debug this problem now.

All the installation of the python packages were performed using

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

Thanks!

I have tried the following test

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

This invoked another question, which I haven't found a solution.

update

This problem has been resolved by updating python from 2.7 to 2.7.15 and reinstall all the depended packages.

Thank you all!

pengchy
  • 732
  • 2
  • 14
  • 26
  • It might help if you show the install command that you used. – Bram Vanroy Sep 03 '18 at 08:49
  • Hi @BramVanroy, thank you for pointing out this lack of information, I have updated the content of the question and added the installation command. – pengchy Sep 03 '18 at 08:58
  • @pengchy still not quite enough. You should show contents of `setup.cfg` in this case, as the error is coming from there. – matejcik Sep 03 '18 at 09:12
  • more constructively: why do you install this way, as opposed to using `pip`? e.g., `pip install mock==2.0.0` – matejcik Sep 03 '18 at 09:12
  • thank you @matejcik, I have updated the content. – pengchy Sep 03 '18 at 09:50
  • thanks for the updates. please also try `pip install mock`, without the version specifier -- unless you actually need mock v2.0.0 – matejcik Sep 03 '18 at 09:53

1 Answers1

0

I had 2 versions of python installed on my centos 7.9. python2.7 and `python3.6.

pip threw me the above error pip3 did succeed.

e.g.
pip install mock ## failed.

pip3 install mock ##Succeeded

Kishor Pawar
  • 3,386
  • 3
  • 28
  • 61