To get the python version, you can use the following code:
import platform
platform.python_version()
For libraries, you have to import them and display the value of __version__
module attribute. (works for all libraries that follows PEP 8 style guide)
import pandas, numpy, matplotlib, seaborn
print(pandas.__version__)
print(numpy.__version__)
print(matplotlib.__version__)
print(seaborn.__version__)