0

In Python calling the import function brings in a module to give a program access to its namespace of classes, functions and variables.

import os
import sys

print(os.name)
print(sys.implementation)

Is there a way to list which modules have already been imported in a program?

>>> list_imports()
sys
os

And if so, is there a way to figure out the version of the imported module?

Jay Godse
  • 15,163
  • 16
  • 84
  • 131

2 Answers2

0

sys.modules is the closest you'll get. Modules following spec will have a __version__ attribute.

Hatshepsut
  • 5,962
  • 8
  • 44
  • 80
0

Just use sys library

import sys
sys.modules.keys()
Ishinomori
  • 229
  • 1
  • 6