bndr / pipreqs

pipreqs - Generate pip requirements.txt file based on imports of any project. Looking for maintainers to move this project forward.
Apache License 2.0
6.38k stars 388 forks source link

SyntaxError: invalid character in identifier #288

Open nise opened 2 years ago

nise commented 2 years ago

Python 3.7.6 pip 21.3.1

$ python3 -m pipreqs.pipreqs . ERROR: Failed on file: ./metadata-env/lib64/python3.7/site-packages/srsly/tests/ujson/test_ujson.py Traceback (most recent call last): File "/home/abb/Applications/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/home/abb/Applications/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/abb/Applications/anaconda3/lib/python3.7/site-packages/pipreqs/pipreqs.py", line 494, in main() # pragma: no cover File "/home/abb/Applications/anaconda3/lib/python3.7/site-packages/pipreqs/pipreqs.py", line 488, in main init(args) File "/home/abb/Applications/anaconda3/lib/python3.7/site-packages/pipreqs/pipreqs.py", line 418, in init follow_links=follow_links) File "/home/abb/Applications/anaconda3/lib/python3.7/site-packages/pipreqs/pipreqs.py", line 131, in get_all_imports raise exc File "/home/abb/Applications/anaconda3/lib/python3.7/site-packages/pipreqs/pipreqs.py", line 117, in get_all_imports tree = ast.parse(contents) File "/home/abb/Applications/anaconda3/lib/python3.7/ast.py", line 35, in parse return compile(source, filename, mode, PyCF_ONLY_AST) File "", line 1 import decimal ^ SyntaxError: invalid character in identifier

Dsantra92 commented 2 years ago

Faced the same issue in Python 3.10

mingjun1120 commented 2 years ago

I found this solution from the CSDN forum (from China) but still, I don't know how to solve it even though I know Mandarin! https://blog.csdn.net/Pragmatism_3568/article/details/105414950