The Python Oracle

How to check if a Python module exists without importing it

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Isolated

--

Chapters
00:00 Question
00:25 Accepted answer (Score 287)
03:55 Answer 2 (Score 45)
04:54 Answer 3 (Score 13)
05:47 Answer 4 (Score 13)
06:09 Thank you

--

Full question
https://stackoverflow.com/questions/1405...

Accepted answer links:
[importlib.util.find_spec(module_name)]: https://docs.python.org/3/library/import...
[Python documentation]: https://docs.python.org/3/library/import...

Answer 2 links:
[ModuleNotFoundError]: https://docs.python.org/3/library/except...
[documentation of the import system]: https://docs.python.org/3/reference/impo...

Answer 4 links:
[yarbelk's response]: https://stackoverflow.com/questions/1405...
[Django]: https://en.wikipedia.org/wiki/Django_%28...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #pythonimport

#avk47