Python 如何指定依赖项';'pip install'命令中的版本?

Python 如何指定依赖项';'pip install'命令中的版本?,python,python-2.7,pytest,Python,Python 2.7,Pytest,我指定在无人机管道中安装pytest,如下所示: pip install -q pytest 它曾经工作得很好,直到几天前突然出现以下错误: + python -m pytest test/test_dai_adrecogzer.py Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main "__main__", fname, lo

我指定在无人机管道中安装
pytest
,如下所示:

pip install -q pytest
它曾经工作得很好,直到几天前突然出现以下错误:

+ python -m pytest test/test_dai_adrecogzer.py
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/pytest.py", line 14, in <module>
    from _pytest.fixtures import fillfixtures as _fillfuncargs
  File "/usr/local/lib/python2.7/dist-packages/_pytest/fixtures.py", line 16, in <module>
    from more_itertools import flatten
  File "/usr/local/lib/python2.7/dist-packages/more_itertools/__init__.py", line 1, in <module>
    from more_itertools.more import *  # noqa
  File "/usr/local/lib/python2.7/dist-packages/more_itertools/more.py", line 329
    def _collate(*iterables, key=lambda a: a, reverse=False):
                               ^

SyntaxError: invalid syntax

我如何将这一建议应用于我的问题?更具体地说,我如何指定版本
您可以指定一个pytest版本,该版本具有旧版本的更多itertools(例如:pip install pytest==3.5.0)


我不建议使用其他版本的迭代器安装pytest,而不是setuptools中指定的迭代器,因为它可能会导致其他问题(pytest它可能在某种程度上取决于降级版本没有的某些功能)

根据,该软件包需要
更多的itertools>=4.0.0
。我假设,如果您在运行
pip install-q pytest
之前,在6.0.0及以上或等于4.0.0的版本下明确安装任何合适的
more itertools
版本,那么对
more itertools
的依赖性检查将已经满足,您可以安装最新版本的
pytest

哦,是的,我使用的是
pip安装-q pytest==3.4.2
,它按照预期工作。
setuptools.setup(
    setup_requires=['pytest-runner'],
    tests_require=['mock', 'more-itertools<6.0.0', 'pytest'],
    test_suite='tests',
    python_requires='>=2.7',
)