any way to tell if user's python environment is anaconda

前端 未结 3 1444
暖寄归人
暖寄归人 2021-02-08 03:40

i\'m distributing an in-house python lib where i\'d like to make it such that if the user is using anaconda when running this file, that updates to the dependencies of the libra

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-08 04:03

    In [109]: import sys
    
    In [110]: 'conda' in sys.version
    Out[110]: True
    

    For version > 3.7, the version info has changed like:

    In [2]: sys.version
    Out[2]: '3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)]'
    

    From this post The solution should be changed to:

    import sys, os
    is_conda = os.path.exists(os.path.join(sys.prefix, 'conda-meta'))
    

提交回复
热议问题