Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jupyter Notebook doesn't Uninstall package with pip [duplicate]

I tried to remove a package with pip in a Jupyter notebook but it never finishes and I have to eventually restart the kernel without it uninstalling. I tried:

!python -m pip uninstall pyserial

I found out why it hangs up. When running it from the command line, it asks whether I want to uninstall with a yes/no required.

Uninstalling pyserial-3.4:
  Would remove:
    c:\Anaconda3\lib\site-packages\pyserial-3.4.dist-info\*
    c:\Anaconda3\lib\site-packages\serial\*
    c:\Anaconda3\scripts\miniterm.py
Proceed (y/n)?

Perhaps the confirmation is a new feature of pip? It doesn't seem to be a problem in How to uninstall a package installed with pip install --user. Is there a way to insert a yes response from the Jupyter notebook to not block future cells from running?

like image 293
Eric Hedengren Avatar asked Feb 06 '20 23:02

Eric Hedengren


People also ask

How do I uninstall a python package in Jupyter notebook?

To uninstall, or remove, a package use the command '$PIP uninstall <package-name>'. This example will remove the flask package. The command will ask for confirmation after listing the files to be removed.

Does pip uninstall work?

pip is able to uninstall most installed packages. Known exceptions are: Pure distutils packages installed with python setup.py install , which leave behind no metadata to determine what files were installed.


1 Answers

Try adding --yes to automatically answer the yes/no question.

!python -m pip uninstall pyserial --yes

This uninstalls the package pyserial. You can use the --yes from the command line or in a Jupyter notebook cell.

Uninstalling pyserial-3.4:
  Successfully uninstalled pyserial-3.4
like image 70
TexasEngineer Avatar answered Oct 26 '22 20:10

TexasEngineer