Skip to content

Instantly share code, notes, and snippets.

@guyskk
Created January 30, 2017 14:35
Show Gist options
  • Save guyskk/7d87b6c8ca26beec9bb70d1598d2f805 to your computer and use it in GitHub Desktop.
Save guyskk/7d87b6c8ca26beec9bb70d1598d2f805 to your computer and use it in GitHub Desktop.
print your platform information and package information
# coding:utf-8
import platform
def pkginfo():
for pkg in ['setuptools', 'pip', 'wheel',
'virtualenv', 'distutils', 'cython']:
try:
version = getattr(__import__(pkg), '__version__', 'Unknown')
print('{} = {}'.format(pkg, version))
except:
print('{} Not Found'.format(pkg))
def platforminfo():
keys = [
'architecture', 'dist', 'java_ver', 'libc_ver',
'linux_distribution', 'mac_ver', 'machine', 'node',
'platform', 'processor', 'python_branch', 'python_build',
'python_compiler', 'python_implementation', 'python_revision',
'python_version', 'python_version_tuple', 'release',
'system', 'system_alias', 'version', 'win32_ver'
]
for k in keys:
try:
v = getattr(platform, k, None)
if callable(v):
v = v()
except:
v = ''
print('{} = {}'.format(k, v))
if __name__ == '__main__':
print('platform information'.center(60, '-'))
platforminfo()
print('package information'.center(60, '-'))
pkginfo()
@FredvanGoor
Copy link

Here is my platform (my linux Mint "Monster-PC") info:

Fred
--------------------platform information--------------------
architecture = ('64bit', 'ELF')
dist = ('LinuxMint', '17', 'qiana')
java_ver = ('', '', ('', '', ''), ('', '', ''))
libc_ver = ('glibc', '2.9')
linux_distribution = ('LinuxMint', '17', 'qiana')
mac_ver = ('', ('', '', ''), '')
machine = x86_64
node = Monster-pc
platform = Linux-3.13.0-24-generic-x86_64-with-LinuxMint-17-qiana
processor = x86_64
python_branch =
python_build = ('default', 'Nov 17 2016 01:08:31')
python_compiler = GCC 4.8.4
python_implementation = CPython
python_revision =
python_version = 3.4.3
python_version_tuple = ('3', '4', '3')
release = 3.13.0-24-generic
system = Linux
system_alias =
version = #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014
win32_ver = ('', '', '', '')
--------------------package information---------------------
setuptools = 3.3
pip = 1.5.4
wheel = 0.29.0
virtualenv Not Found
distutils = 3.4.3
cython = 0.25.2


(program exited with code: 0)
Press return to continue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment