Pipreqs schlägt beim Scannen von Python 2 -Code in einer Python 3 -Umgebung mit SyntaxError fehlPython

Python-Programme
Anonymous
 Pipreqs schlägt beim Scannen von Python 2 -Code in einer Python 3 -Umgebung mit SyntaxError fehl

Post by Anonymous »

Ich habe eine virtuelle Python3 -Umgebung, aber es gibt einige python2 -syntaxierte Dateien. Ich versuche, die Anforderung zu erhalten.

Code: Select all

INFO: Not scanning for jupyter notebooks.
ERROR: Failed on file: ./tests/data/python2.py
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "/Users/plus1/Desktop/black/venv/lib/python3.12/site-packages/pipreqs/pipreqs.py", line 615, in 
main()  # pragma: no cover
^^^^^^
File "/Users/plus1/Desktop/black/venv/lib/python3.12/site-packages/pipreqs/pipreqs.py", line 609, in main
init(args)
File "/Users/plus1/Desktop/black/venv/lib/python3.12/site-packages/pipreqs/pipreqs.py", line 533, in init
candidates = get_all_imports(
^^^^^^^^^^^^^^^^
File "/Users/plus1/Desktop/black/venv/lib/python3.12/site-packages/pipreqs/pipreqs.py", line 153, in get_all_imports
raise exc
File "/Users/plus1/Desktop/black/venv/lib/python3.12/site-packages/pipreqs/pipreqs.py", line 139, in get_all_imports
tree = ast.parse(contents)
^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ast.py", line 52, in parse
return compile(source, filename, mode, flags,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 7
print >> sys.stderr , "Look, a repr:", `sys`
^
SyntaxError: invalid syntax
< /code>
Und die errorierende Datei sieht unten aus: < /p>
#!/usr/bin/env python2

import sys

print >> sys.stderr , "Warning:" ,
print >> sys.stderr , "this is a blast from the past."
print >> sys.stderr , "Look, a repr:", `sys`

def function((_globals, _locals)):
exec ur"print 'hi from exec!'" in _globals, _locals

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post