python 2.7 - Requirement.parse('six>=1.6.0'

2019-03-05 06:34发布

问题:

Python ... why does this happen?

All of a sudden I get this error:

Traceback (most recent call last):
  File "setup.py", line 36, in <module>
    zip_safe=False) 
  File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
    _setup_distribution = dist = klass(attrs)
  File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 320, in __init__
    _Distribution.__init__(self, attrs)
  File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
    self.finalize_options()
  File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 386, in finalize_options
    ep.require(installer=self.fetch_build_egg)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2324, in require
    items = working_set.resolve(reqs, env, installer, extras=self.extras)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 859, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (six 1.5.2 (/usr/lib/python2.7/dist-packages), Requirement.parse('six>=1.6.0'))

when I run python setup.py develop

Here is my setup.py file

from setuptools import setup

setup(name='bootops',
      version='0.1.1',
      description='Boo',
      url='http://github.com/boo/bootops',
      author='dude',
      author_email='dude',
      license='GPLv3',
      packages=['bootops'],
      package_data={'bootops': ['classes/*.py','classes/syptec/*.py','classes/syptec/tools/*.py']},
      entry_points = {
        "console_scripts": ['bootops = bootops.bootops:main']
      },
      install_requires=[
          'six==1.6.0',    
          'setuptools>=11.3',    
          'boto',
          'zc.zk',
          'paramiko>=2.0',
          'apache-libcloud',
          'requests>=2.9.1',
          'pyyaml',
          'pytz',
          'gevent',
          'redis>=2.10.5',
          'dnspython',
          'jinja2',
          'netaddr',
          'python-nmap',
          'scapy',
          'hashids'
      ],
      zip_safe=False) 

I added the below to setup file yet I still get the error: six==1.6.0

If I run:

pip install six==1.6.0
python setup.py develop

Then it works!

I mean wowee. Why setup and deal with the issues by its self?

回答1:

The setup file requires you to have a version of the six module greater than 1.6.0 but you had version 1.5.2 installed, so it raises a VersionConflict exception. When you install the appropriate version of six, it runs correctly because you've met all of the versioning requirements in your setup.py file.