question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SyntaxError: invalid syntax

See original GitHub issue

When running pipenv I’m getting a syntax error. python -m pipenv.help also results in a Syntax error.

This might be due to pipenv although I’m not completely convinced. Any direction, hints or ideas would be appreciated

Python 3.5.2 (via pyenv) pip 9.0.1 from /Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages (python 3.5) pipenv (11.8.0) installed via pip MacOS Sierra


Expected result

No syntax errors

Actual result

Stacktrace output:

$ python -m pipenv.help                                                                                                                                                     [17:06:06]
Traceback (most recent call last):
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/help.py", line 9, in <module>
    from .core import project, system_which, find_python_in_path, python_version
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/core.py", line 24, in <module>
    import pipdeptree
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/vendor/pipdeptree.py", line 16, in <module>
    import pip9
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/vendor/pip9/__init__.py", line 28, in <module>
    from pip9.vcs import git, mercurial, subversion, bazaar  # noqa
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/vendor/pip9/vcs/subversion.py", line 9, in <module>
    from pip9.index import Link
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/vendor/pip9/index.py", line 31, in <module>
    from pip9.wheel import Wheel, wheel_ext
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/vendor/pip9/wheel.py", line 6, in <module>
    import compileall
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/compileall.py", line 20, in <module>
    from concurrent.futures import ProcessPoolExecutor
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/../concurrent/futures/__init__.py", line 8, in <module>
    from concurrent.futures._base import (FIRST_COMPLETED,
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/../concurrent/futures/_base.py", line 414
    raise exception_type, self._exception, self._traceback
                        ^
SyntaxError: invalid syntax
FAIL: 1


$ pipenv                                                                                                                                                                    [17:15:16]
Traceback (most recent call last):
  File "/Users/pglombardo/.pyenv/versions/3.5.2/bin/pipenv", line 11, in <module>
    load_entry_point('pipenv==11.8.0', 'console_scripts', 'pipenv')()
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 696, in main
    with self.make_context(prog_name, args, **extra) as ctx:
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 621, in make_context
    self.parse_args(ctx, args)
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 1018, in parse_args
    rest = Command.parse_args(self, ctx, args)
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 875, in parse_args
    parser = self.make_parser(ctx)
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 821, in make_parser
    for param in self.get_params(ctx):
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 774, in get_params
    help_option = self.get_help_option(ctx)
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/cli.py", line 26, in get_help_option
    from .import core
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/core.py", line 23, in <module>
    import pipdeptree
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/vendor/pipdeptree.py", line 16, in <module>
    import pip9
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/vendor/pip9/__init__.py", line 28, in <module>
    from pip9.vcs import git, mercurial, subversion, bazaar  # noqa
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/vendor/pip9/vcs/subversion.py", line 9, in <module>
    from pip9.index import Link
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/vendor/pip9/index.py", line 31, in <module>
    from pip9.wheel import Wheel, wheel_ext
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/vendor/pip9/wheel.py", line 6, in <module>
    import compileall
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/compileall.py", line 20, in <module>
    from concurrent.futures import ProcessPoolExecutor
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/../concurrent/futures/__init__.py", line 8, in <module>
    from concurrent.futures._base import (FIRST_COMPLETED,
  File "/Users/pglombardo/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pipenv/../concurrent/futures/_base.py", line 414
    raise exception_type, self._exception, self._traceback
                        ^
SyntaxError: invalid syntax
FAIL: 1
Steps to replicate

run any command with pipenv

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
damousecommented, Mar 16, 2018

The issue seems to arise from having futures installed in python 3 via pip, which is meant to backport functionality already baked into recent versions of python3. This is not the same as #1738, which has futures installed in 2.7-- this one is a little more obvious.

You can tell if you have the problem if you see that the exception is being thrown from python3.X/site-packages/concurrent or pip3 freeze contains:

futures==3.1.1

The fix is to uninstall the package:

pip3 uninstall futures

Verifying that importing concurrent.futures resolves to the system version:

~ $ python3
Python 3.6.2 (default, Aug 28 2017, 16:38:53) 
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import concurrent.futures
>>> concurrent.futures.__file__
'/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/concurrent/futures/__init__.py'

No more issues with pipenv after this.

1reaction
uranusjrcommented, Mar 20, 2018

@KeynesYouDigIt You might want to make sure you’re running a recent version of Pipenv though. I believe the situation has been greately improved in 11.8.3. You might not need to uninstall futures if the changes work for you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid Syntax in Python: Common Reasons for SyntaxError
The interpreter will find any invalid syntax in Python during this first stage of program execution, also known as the parsing stage. If...
Read more >
How to Fix Invalid SyntaxError in Python - Rollbar
The Python SyntaxError occurs when the interpreter encounters invalid syntax in code. When Python code is executed, the interpreter parses ...
Read more >
python - Why do I get the syntax error "SyntaxError: invalid ...
When an error is reported on a line that appears correct, try removing (or commenting out) the line where the error appears to...
Read more >
SyntaxError: invalid syntax - Python Morsels
Python's "invalid syntax" error message comes up often, especially when you're first learning Python. What usually causes this error and how can you...
Read more >
SyntaxError in Python: How to Handle Invalid Syntax in Python
In this tutorial, I will teach you how to handle SyntaxError in Python, including numerous strategies for handling invalid syntax in Python.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found