When you need to generate the package and corresponding version required by a project, you can first CD it to the project directory, and then enter:
pipreqs ./
Code error is reported as follows:
Traceback (most recent call last):
File "f:\users\asus\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "f:\users\asus\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "F:\Users\asus\Anaconda3\Scripts\pipreqs.exe\__main__.py", line 7, in <module>
File "f:\users\asus\anaconda3\lib\site-packages\pipreqs\pipreqs.py", line 470, in main
init(args)
File "f:\users\asus\anaconda3\lib\site-packages\pipreqs\pipreqs.py", line 409, in init
follow_links=follow_links)
File "f:\users\asus\anaconda3\lib\site-packages\pipreqs\pipreqs.py", line 122, in get_all_imports
contents = f.read()
File "f:\users\asus\anaconda3\lib\codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbb in position 570: invalid start byte
Find line 122 of pipreqs.py and modify the coding format to iso-8859-1.
with open_func(file_name, "r", encoding='ISO-8859-1') as f:
contents = f.read()
After trying many encoding formats, such as GBK, GB18030, etc., errors are still reported until iso-8859-1 is used. The specific reason is that the parameter setting of decode is too strict. It is set to igonre, but it is not found where the decode function is changed. Change it when you find it later.
Read More:
- Python automatically generates the requirements file for the current project
- When sending an email, an error was reported: AttributeError:’list’ object has no attribute’encode’
- [Solved] ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE
- [Solved] RuntimeError: a view of a leaf Variable that requires grad is being used in an in-place
- [Solved] RuntimeError: a view of a leaf Variable that requires grad is being used in an in-place operation
- [Solved] lto1: fatal error: bytecode stream..generated with LTO version 6.2 instead of the expected 8.1 compi
- SyntaxError: Non-UTF-8 code starting with ‘\xe4‘ in file [How to Solve Chinese encoding problem]
- [Solved] ERROR: Cannot uninstall ‘PyYAML‘. It is a distutils installed project and thus we cannot accurately
- [Solved] Error starting proxy server: oserror (10013), “an attempt was made to access the socket in a way that the access permission is not allowed.”, None, 10013, None)
- Python3 Error: Cannot uninstall ‘numpy’. It is a distutils installed project and thus we cannot accurate
- Python installs virtualenv through PIP and always reports an error: response.py“, line 438, in _error_catcher yield
- [Solved] ERROR: Cannot uninstall ‘wrapt‘. It is a distutils installed project and thus we cannot accurately d
- KeyError: b ‘TEST’ problem in python3 conversion from csn-rcnn code
- [Solved] SyntaxError: Non-UTF-8 code starting with ‘\xe6‘ in file
- An introduction to sys modules in Python and how packages are imported and used
- [Solved] bert_as_service startup error: Tensorflow 2.1.0 is not tested!
- Pandas ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.an
- [Solved] Grid Search Error (GridSearchCV): ‘ascii‘ codec can‘t encode characters in position 18-20: ordinal not in r
- [Solved] error in REfO setup command: use_2to3 is invalid.
- [Solved] Python Project Error: django.core.exceptions.ImproperlyConfigured: WSGI application ‘WebTool.wsgi.application