Python 標準ライブラリ sysconfig Python構成情報
Publish date: 2022-02-11
Pythonの構成情報を取得する。
概要
import sysconfig
sysconfig.get_python_version()
# => 3.9
sysconfig.get_platform()
# => 'win-amd64'
sysconfig.get_scheme_names()
# => ('nt',
# 'nt_user',
# 'osx_framework_user',
# 'posix_home',
# 'posix_prefix',
# 'posix_user')
sysconfig.get_path_names()
# => ('stdlib', 'platstdlib', 'purelib', 'platlib', 'include', 'scripts', 'data')
sysconfig.get_paths()
# => {'stdlib': 'C:\\Users\\testuser\\AppData\\Local\\Programs\\Python\\Python39\\Lib',
# 'platstdlib': 'c:\\home\\workspace\\sample\\Lib',
# 'purelib': 'c:\\home\\workspace\\sample\\Lib\\site-packages',
# 'platlib': 'c:\\home\\workspace\\sample\\Lib\\site-packages',
# 'include': 'C:\\Users\\testuser\\AppData\\Local\\Programs\\Python\\Python39\\Include',
# 'platinclude': 'C:\\Users\\testuser\\AppData\\Local\\Programs\\Python\\Python39\\Include',
# 'scripts': 'c:\\home\\workspace\\sample\\Scripts',
# 'data': 'c:\\home\\workspace\\sample'}