Check if module exists, if not install it

前端 未结 8 1639
北海茫月
北海茫月 2020-12-08 07:41

I want to check if a module exists, if it doesn\'t I want to install it.

How should I do this?

So far I have this code which correctly prints f

8条回答
  •  隐瞒了意图╮
    2020-12-08 08:11

    NOTE: Ipython / Jupyter specific solution.

    While using notebooks / online kernels, I usually do it using systems call.

    try:
      import keyring
    except:
      !pip install pulp
      import keyring
    

提交回复
热议问题