Home  >  Article  >  Backend Development  >  How to check the third-party libraries and their versions that a Python script depends on?

How to check the third-party libraries and their versions that a Python script depends on?

WBOY
WBOYforward
2023-04-23 14:40:074415browse

1. First install the pipreqs library

Use the pip command and use the Douban image. The command is as follows:

pip install pipreqs -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

How to check the third-party libraries and their versions that a Python script depends on?

2. Open Terminal in pycharm

How to check the third-party libraries and their versions that a Python script depends on?

3. In terminal, if you want to view the packages that the script in the test folder depends on, enter the following Command:

pipreqs ./test --encoding=utf8 --force

How to check the third-party libraries and their versions that a Python script depends on?

When INFO: Successfully saved requirements file in ./test\requirements.txt appears, it means the operation is successful

4. In the test folder, you can see that a new requirements.txt file has been created. Open the file to view the packages and versions that the script depends on:

How to check the third-party libraries and their versions that a Python script depends on?

How to check the third-party libraries and their versions that a Python script depends on?

This way you can see the packages and versions that the script depends on

5. If you need to migrate the project to other environments or machines, use the following Method to install dependent packages:

pip install -r requirements.txt -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

How to check the third-party libraries and their versions that a Python script depends on?

The above is the detailed content of How to check the third-party libraries and their versions that a Python script depends on?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete