Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Python script for reporting runtime environment
#! /usr/bin/env python3
import platform
import pip
import sys
def pip_freeze():
from pip._internal.operations import freeze
except ImportError: # pip < 10.0
from pip.operations import freeze
return freeze.freeze()
def print_sys_info():
print('# Platform\n')
print('platform :', platform.platform())
print('system :', platform.system())
print('node :', platform.node())
print('release :', platform.release())
print('version :', platform.version())
print('machine :', platform.machine())
print('processor:', platform.processor())
print('# Python Interpreter\n')
print('Python Version :', platform.python_version())
print('Compiler :', platform.python_compiler())
print('Build :', platform.python_build())
def main( output='stdout' ):
if output is not 'stdout':
sys.stdout = open(output, 'w')
print( '# Frozen Python Modules\n' )
for p in pip_freeze():
print( p )
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.