Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • 1
    Yes, the pkgutil version will only return modules that are present as files. So the modules that come builtin, compiled right into python won't be included. This is usually not a problem as such scripts are typically used for dependency scanning, and you don't care about builtins in such case — grats on hitting 10k btw ;). Commented May 19, 2020 at 14:23
  • If you look where help('modules') is implemented, github.com/python/cpython/blob/… you can just copy/paste that code and get the output in a list, parsing the stdout of a function call is hacky. Commented Jan 23, 2021 at 2:14