Search code examples
pythonpipjupyter-labgcp-ai-platform-notebook

How to uninstall a package in AI platform JupyterLab notebook?


I want to uninstall a package from an AI platform notebook

!pip3 uninstall statsmodels

However, I get this response and cannot reply y/n

found existing installation: statsmodels 0.11.1
Uninstalling statsmodels-0.11.1:
  Would remove:
    /home/jupyter/.local/lib/python3.5/site-packages/statsmodels-0.11.1.dist-info/*
    /home/jupyter/.local/lib/python3.5/site-packages/statsmodels/*
Proceed (y/n)? 

I could try to do it from terminal, but I notice what I do in terminal isn't the same as within the notebook. Like if I run pip freeze, I get a different set of packages installed from notebook vs terminal


Solution

  • Just like on the command line, you can pass in the answer in advance:

    !echo y | pip3 uninstall statsmodels