The Python project automatically generates the requirements file for the current project

Source: Internet
Author: User
Tags virtual environment

Using PIP freeze
$ pip freeze > requirements.txt

This approach is to list the entire package in the environment, if it is a virtual environment that can be used.
Normally we only need to export the requirements.txt of the current project, so we recommend Pipreqs.

Using Pipreqs

This tool is a good helper, can be scanned by the project directory, automatically discover the use of those class libraries, automatically generate a dependency list, only build project-related dependencies to Requirements.txt

Installation
pip install pipreqs
Use

Very simple to use PIPREQS path name
This goes directly to the project root, so yes./

pipreqs ./
Error
  File "c:\users\devtao\appdata\local\programs\python\python36-32\lib\site-packages\pipreqs\pipreqs.py", line 341, in init    extra_ignore_dirs=extra_ignore_dirs)  File "c:\users\devtao\appdata\local\programs\python\python36-32\lib\site-packages\pipreqs\pipreqs.py", line 75, in get_all_imports    contents = f.read()UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xa6 in position 186: illegal multibyte sequence

If there is an error similar to the top unicodedecodeerror: ' GBK ' codec can ' t decode byte 0xa6 in position 186:illegal multibyte sequence
Modify the pipreqs.py 75 line directly and change the encoding to Utf-8

The Python project automatically generates the requirements file for the current project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.