search

Home  >  Q&A  >  body text

How to automatically install third-party libraries in python?

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?

怪我咯怪我咯2730 days ago1024

reply all(2)I'll reply

  • 世界只因有你

    世界只因有你2017-07-05 10:36:46

    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

    reply
    0
  • 为情所困

    为情所困2017-07-05 10:36:46

    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.

    reply
    0
  • Cancelreply