How to automatically install third-party libraries in python?
怪我咯2017-07-05 10:34:46
0
2
996
For example, if the third-party requests library is used in the script, when it is run by others, it may prompt that the library is missing. Is there any way to catch this exception and directly help the user to install it automatically?
You should write all the libraries you use into the requirements.txt file before letting others use the script Then run pip install -r requirements.txt
It can actually be done, but can you ensure that the missing module has the same name as the installed package? There are also version issues that need to be considered. Therefore, it is better to solve all the dependencies before thinking about this problem.
You should write all the libraries you use into the requirements.txt file before letting others use the script
Then run pip install -r requirements.txt
It can actually be done, but can you ensure that the missing module has the same name as the installed package? There are also version issues that need to be considered. Therefore, it is better to solve all the dependencies before thinking about this problem.