当我使用pipreqs时,我遇到了这个问题,我使用了anaconda和俄语Windows。
root@DESKTOP-ETLLRI1 C:\Users\root\Desktop\resumes
$ pipreqs C:\Users\root\Desktop\resumes
Traceback (most recent call last):
File "C:\Users\root\Anaconda3\Scripts\pipreqs-script.py", line 9, in <module>
sys.exit(main())
File "C:\Users\root\Anaconda3\lib\site-packages\pipreqs\pipreqs.py", line 396, in main
init(args)
File "C:\Users\root\Anaconda3\lib\site-packages\pipreqs\pipreqs.py", line 341, in init
extra_ignore_dirs=extra_ignore_dirs)
File "C:\Users\root\Anaconda3\lib\site-packages\pipreqs\pipreqs.py", line 75, in get_all_imports
contents = f.read()
File "C:\Users\root\Anaconda3\lib\encodings\cp1251.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 1206: character maps to <undefined>
答案 0 :(得分:1)
You can pass an encoding argument to pipreqs
so that it know which encoding to use to open files.
Python3 files are usually encoded as utf-8, so execute
pipreqs --encoding=utf8 C:\Users\root\Desktop\resumes
答案 1 :(得分:0)
BOM符号问题。
P:> pipreqs --encoding = utf8 / app 错误:文件失败:/ app \ database.py
Traceback (most recent call last):
File "i:\python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "i:\python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "I:\Python37\Scripts\pipreqs.exe\__main__.py", line 9, in <module>
File "i:\python37\lib\site-packages\pipreqs\pipreqs.py", line 470, in main
init(args)
File "i:\python37\lib\site-packages\pipreqs\pipreqs.py", line 409, in init
follow_links=follow_links)
File "i:\python37\lib\site-packages\pipreqs\pipreqs.py", line 138, in get_all_imports
raise exc
File "i:\python37\lib\site-packages\pipreqs\pipreqs.py", line 124, in get_all_imports
tree = ast.parse(contents)
File "i:\python37\lib\ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 1
# -*- coding: utf-8 -*-
^
SyntaxError: invalid character in identifier