SyntaxError: invalid syntax
See original GitHub issueWhen 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:
- Created 6 years ago
- Comments:15 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 hasfutures
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
orpip3 freeze
contains:The fix is to uninstall the package:
Verifying that importing
concurrent.futures
resolves to the system version:No more issues with pipenv after this.
@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.