SyntaxError: invalid syntax in lambda function
See original GitHub issueSteps to recreate error:
- Install pipreqs
sudo pip install pipreqs
- Use pipreqs
pipreqs fosscell-django/
fosscell-django is my virtualenv project directory and virtualenv is not active in any step
Error log
ERROR: Failed on file: fosscell-django/lib/python3.8/site-packages/openid/urinorm.py
Traceback (most recent call last):
File "/usr/bin/pipreqs", line 8, in <module>
sys.exit(main())
File "/usr/lib/python3.8/site-packages/pipreqs/pipreqs.py", line 470, in main
init(args)
File "/usr/lib/python3.8/site-packages/pipreqs/pipreqs.py", line 406, in init
candidates = get_all_imports(input_path,
File "/usr/lib/python3.8/site-packages/pipreqs/pipreqs.py", line 138, in get_all_imports
raise exc
File "/usr/lib/python3.8/site-packages/pipreqs/pipreqs.py", line 124, in get_all_imports
tree = ast.parse(contents)
File "/usr/lib/python3.8/ast.py", line 47, in parse
return compile(source, filename, mode, flags,
File "<unknown>", line 76
map(lambda (m, n): u'%s-%s' % (unichr(m), unichr(n)),
^
SyntaxError: invalid syntax
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
Why do parentheses in a lambda function cause syntax ...
Using parentheses to unpack the arguments in a lambda is not allowed in Python3. See PEP 3113 for the reason why. lambda (k,...
Read more >Why am I getting this syntax error when using a lambda ...
I have a list called "team_objects" which contains objects of the same class that all have the attribute "points".
Read more >Lambda function invalid syntax · Issue #32
I had actually tried that url = m.send(lambda file_path, display_name: print '*') , but seems to give an error too. File "test.py ...
Read more >How To Use Python Lambda Functions
A lambda function can contain only expressions and cannot include any statements. It will raise a SyntaxError upon using statements like return, ...
Read more >Lambda with if but without else in Python
The above code on execution shows SyntaxError, as we know that a lambda function must return a value and this function returns x*x...
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
That solved it. Thank you @jonafato . I uninstalled python-openid which was unused in my Python 3 project.
I see now. I missed that this was a third-party package at first. I suspect that this code is not imported by your django project and wouldn’t work if it was. The line in question is https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/urinorm.py#L76. Per the Requirements section of the README, python-openid is Python 2 only. I see some issues referencing https://github.com/necaris/python3-openid as an alternative, but I don’t use either library and can’t speak to that personally. I’d recommend removing that library from your project, but if you’d simply like to ignore that directory, you can use the
--ignore
flag withpipreqs
.