pipreqs icon indicating copy to clipboard operation
pipreqs copied to clipboard

SyntaxError in python 3.10

Open ivholmlu opened this issue 1 year ago • 2 comments

When calling

pipreqgs . --force

I get this error. Seems like it is running or generating some python 2 code, considering the print statement lacks parentheses.. Is there a fix/workaround for this?

File "/pathtomyproject/lvenv/lib/python3.10/site-packages/pipreqs/pipreqs.py", line 139, in get_all_imports tree = ast.parse(contents) File "/usr/lib/python3.10/ast.py", line 50, in parse return compile(source, filename, mode, flags, File "", line 309 print self.entity.table.repr2() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?

ivholmlu avatar Aug 22 '24 08:08 ivholmlu

This error seems to be produced from the codebase which you are trying to parse. Can you add the complete traceback to help you better?

return compile(source, filename, mode, flags,
File "", line 309 # <<< file name missing in traceback
print self.entity.table.repr2()

DataEnggNerd avatar Oct 25 '24 02:10 DataEnggNerd

It's because it's Python 2. Can you upgrade the file maybe?

jonas-eschle avatar Apr 07 '25 16:04 jonas-eschle