Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in more.py during pytest in Python 2.7 #272

Closed
joshuahendinata opened this issue Feb 12, 2019 · 16 comments
Closed

Error in more.py during pytest in Python 2.7 #272

joshuahendinata opened this issue Feb 12, 2019 · 16 comments

Comments

@joshuahendinata
Copy link

joshuahendinata commented Feb 12, 2019

I received this error in version 6.0 (released just now in PyPi) when running pytest which depends on more-itertools. I am using python 2.7

def _collate(*iterables, key=lambda a: a, reverse=False):
                           ^
SyntaxError: invalid syntax

Edited to add: For people finding this issue from Google, the issue is with Python 2.7. For a version more more-itertools that works with that version of Python, pip install more_itertools==5.0.0.

@joshuahendinata
Copy link
Author

I think this is more appropriate to be filed under pytest repo instead pytest-dev/pytest#4770

@MSeifert04
Copy link
Contributor

MSeifert04 commented Feb 12, 2019

Starting with 6.0 the more_itertools package dropped Support for Python 2.

@MSeifert04
Copy link
Contributor

See #253

@RonnyPfannschmidt
Copy link

its not clear to me why this version is installed on python2.7 at all, i suspect too old pip

@MSeifert04
Copy link
Contributor

MSeifert04 commented Feb 12, 2019

Yes, I also thought that python_requires='>=3.4' would prevent it from installing in Python 2.x. Or is that something home-brewed non-standard?

@RonnyPfannschmidt
Copy link

@MSeifert04 its th standard, i tested with pip as old as 9.x and it works

@yfried
Copy link

yfried commented Feb 12, 2019

this happens for pip<9:

$ pip install -U "pip<9"
...
Successfully installed pip-8.1.2
$ pip install pytest
...
Collecting more-itertools>=4.0.0 (from pytest)
  Downloading https://files.pythonhosted.org/packages/dd/f4/cdfbb6f07f767e0cd8a11b16adfecc735b6eb87dbebda026ce8898e1cc22/more-itertools-6.0.0.tar.gz (68kB)

@webknjaz
Copy link

@MSeifert04 turns out that it's 5.0.0 that doesn't support Python 2 but has broken metadata...

@bbayles
Copy link
Collaborator

bbayles commented Sep 24, 2019

If there's something I screwed up, I'd accept a patch against the 5.0.0 tag and push it to PyPI.

@webknjaz
Copy link

Looks like it has the same syntax error: https://ci.appveyor.com/project/cherrypy/cheroot/build/job/vgj5rxqpj9tb6xg1#L71.

@webknjaz
Copy link

Which is weird. That CI log says that it has installed v5.0.0 but, according to Git, it's fine: https://github.com/erikrose/more-itertools/blob/5.0.0/more_itertools/more.py#L359.

I'm curious whether PyPI dists correspond what's in Git...

@webknjaz
Copy link

No, dist has the correct code. So it's probably something that's shadowed by tox...

@ssbarnea
Copy link

ssbarnea commented Nov 8, 2019

Any idea on how to avoid getting an unsupported version of more_itertools?

Command output
distro run-test: commands[1] | docker build --build-arg TEST_IMAGE=pycontribs/centos:7 .
Sending build context to Docker daemon  54.06MB
Step 1/5 : ARG TEST_IMAGE=pycontribs/centos:7
Step 2/5 : FROM $TEST_IMAGE
 ---> 9c7cec43604f
Step 3/5 : ADD . /app
 ---> 73f7fe532c9b
Step 4/5 : WORKDIR /app
 ---> Running in 0d714e42051f
Removing intermediate container 0d714e42051f
 ---> 8fe93343d235
Step 5/5 : RUN PY=`command -v python3 python 2>/dev/null | head -1` && $PY --version && $PY -m pip install importlib-metadata && $PY -m pip install . && $PY -m pre_commit run --color=always -v -a || { cat /root/.cache/pre-commit/pre-commit.log; exit 1; }
 ---> Running in e4d00e64e009
Python 2.7.5
Collecting importlib-metadata
  Downloading https://files.pythonhosted.org/packages/f6/d2/40b3fa882147719744e6aa50ac39cf7a22a913cbcba86a0371176c425a3b/importlib_metadata-0.23-py2.py3-none-any.whl
Collecting configparser>=3.5; python_version < "3" (from importlib-metadata)
  Downloading https://files.pythonhosted.org/packages/7a/2a/95ed0501cf5d8709490b1d3a3f9b5cf340da6c433f896bbe9ce08dbe6785/configparser-4.0.2-py2.py3-none-any.whl
Collecting zipp>=0.5 (from importlib-metadata)
  Downloading https://files.pythonhosted.org/packages/74/3d/1ee25a26411ba0401b43c6376d2316a71addcc72ef8690b101b4ea56d76a/zipp-0.6.0-py2.py3-none-any.whl
Collecting contextlib2; python_version < "3" (from importlib-metadata)
  Downloading https://files.pythonhosted.org/packages/85/60/370352f7ef6aa96c52fb001831622f50f923c1d575427d021b8ab3311236/contextlib2-0.6.0.post1-py2.py3-none-any.whl
Collecting pathlib2; python_version == "3.4.*" or python_version < "3" (from importlib-metadata)
  Downloading https://files.pythonhosted.org/packages/e9/45/9c82d3666af4ef9f221cbb954e1d77ddbb513faf552aea6df5f37f1a4859/pathlib2-2.3.5-py2.py3-none-any.whl
Collecting more-itertools (from zipp>=0.5->importlib-metadata)
  Downloading https://files.pythonhosted.org/packages/c2/31/45f61c8927c9550109f1c4b99ba3ca66d328d889a9c9853a808bff1c9fa0/more-itertools-7.2.0.tar.gz (73kB)
Collecting six (from pathlib2; python_version == "3.4.*" or python_version < "3"->importlib-metadata)
  Downloading https://files.pythonhosted.org/packages/65/26/32b8464df2a97e6dd1b656ed26b2c194606c16fe163c695a992b36c11cdf/six-1.13.0-py2.py3-none-any.whl
Collecting scandir; python_version < "3.5" (from pathlib2; python_version == "3.4.*" or python_version < "3"->importlib-metadata)
  Downloading https://files.pythonhosted.org/packages/df/f5/9c052db7bd54d0cbf1bc0bb6554362bba1012d03e5888950a4f5c5dadc4e/scandir-1.10.0.tar.gz
Installing collected packages: configparser, more-itertools, zipp, contextlib2, six, scandir, pathlib2, importlib-metadata
  Running setup.py install for more-itertools: started
    Running setup.py install for more-itertools: finished with status 'done'
  Running setup.py install for scandir: started
    Running setup.py install for scandir: finished with status 'done'
Successfully installed configparser-4.0.2 contextlib2-0.6.0.post1 importlib-metadata-0.23 more-itertools-7.2.0 pathlib2-2.3.5 scandir-1.10.0 six-1.13.0 zipp-0.6.0
You are using pip version 8.1.2, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Processing /app
Installing collected packages: UNKNOWN
  Running setup.py install for UNKNOWN: started
    Running setup.py install for UNKNOWN: finished with status 'done'
Successfully installed UNKNOWN-0.0.0
You are using pip version 8.1.2, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/app/pre_commit/__main__.py", line 3, in <module>
    from pre_commit.main import main
  File "pre_commit/main.py", line 8, in <module>
    import pre_commit.constants as C
  File "pre_commit/constants.py", line 7, in <module>
    import importlib_metadata
  File "/usr/lib/python2.7/site-packages/importlib_metadata/__init__.py", line 9, in <module>
    import zipp
  File "/usr/lib/python2.7/site-packages/zipp.py", line 12, in <module>
    import more_itertools
  File "/usr/lib/python2.7/site-packages/more_itertools/__init__.py", line 1, in <module>
    from more_itertools.more import *  # noqa
  File "/usr/lib/python2.7/site-packages/more_itertools/more.py", line 340
    def _collate(*iterables, key=lambda a: a, reverse=False):
                               ^
SyntaxError: invalid syntax
cat: /root/.cache/pre-commit/pre-commit.log: No such file or directory

@hugovk
Copy link
Contributor

hugovk commented Nov 8, 2019

You should consider upgrading via the 'pip install --upgrade pip' command.

First thing to try, upgrade pip. Modern pip makes use of the python_requires value in setup.py.

@webknjaz
Copy link

webknjaz commented Nov 8, 2019

You are using pip version 8.1.2, however version 19.3.1 is available.

python_requires is supported since Pip 9.0.0.

@webknjaz
Copy link

Cross-posting a similar Python 3.5 bug: #578.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants