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
2. Open Terminal in pycharm
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
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:
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
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!