How to get the list of options that Python was compiled with?

后端 未结 5 1865
北荒
北荒 2020-12-07 09:43

You can compile Python in various ways. I\'d like to find out with which options my Python was compiled.

Concrete use-case: was my Python compiled with readline? I k

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 10:29

    There is a module to see the system config

    import sysconfig
    print(sysconfig.get_config_vars())
    

    It offers an interface to get individual variables as well.

    sysconfig.get_config_var('HAVE_LIBREADLINE')
    

    Edit:

    before python2.7, you have to use

    import distutils.sysconfig
    print distutils.sysconfig.get_config_vars()
    

提交回复
热议问题