Quite simply, is there a python equivalent to php's phpinfo();
? If so, what is it and how do I use it (a link to a reference page would work great).
5 Answers
Check this one out!
pyinfo() A good looking phpinfo-like python script
2023 Update: this script has been moved to Gist,
but more importantly: one of the commenters made it compatible with Python 3

- 761
- 8
- 17
-
The link here is now dead. Is there a new one? - however, https://pypi.org/project/pyinfo/ and https://github.com/mastropinguino/pyinfo – rfay Apr 04 '23 at 21:28
-
However, I'm not able to get this to work in current python 3.9.2 – rfay Apr 04 '23 at 21:44
-
1@rfay I've just fixed the link to a web archive version, and added the code from the original gist. There's also a [pyinfo() for python 3](https://gist.github.com/branneman/951825?permalink_comment_id=1611004#gistcomment-1611004) from a commenter. – Bran van der Meer Apr 06 '23 at 07:15
Did you try this out: http://www.webhostingtalk.com/showpost.php?s=f55e18d344e3783edd98aef5be809ac8&p=4632018&postcount=4

- 3,498
- 5
- 27
- 32
There is nothing directly comparable to phpinfo()
, but you can get some bits of information ...
>>> import sys
>>> sys.version
'2.6.4 (r264:75706, Feb 6 2010, 01:49:44) \n[GCC 4.2.1 (Apple Inc. build 5646)]'
>>> sys.platform
'darwin'
>>> sys.modules.keys()
['copy_reg', 'sre_compile', '_sre', 'encodings', 'site', ... ]
>>> import os
>>> os.name
'posix'
>>> import platform
>>> platform.architecture()
('32bit', '')
>>> platform.machine()
'i386'
...

- 181,842
- 47
- 306
- 310
Afaik there is no similar function. However, the platform module allows you to access some basic information about the machine, OS and Python.

- 278,196
- 72
- 453
- 469
phpinfo prints information about running PHP version, loaded modules and so on.
AFAIK Python does not such a conventient function that dumps the complete configuration.
But you should have a look at the sys
package.
import sys
# print all imported modules since start
print sys.modules
# print load path
print sys.path
...
Check out Python's sys-library reference.

- 878
- 6
- 14