问题
Runnig py -m pip list
in windows powershell, produces:
Package Version
--------------- -------
-umpy 1.15.4
autogui 0.1.8
beautifulsoup4 4.8.0
cycler 0.10.0
et-xmlfile 1.0.1
...and so on
as you can see there is a package named -umpy
which must be some kind of a computer hiccup.
Now I want to uninstall this package but the py -m pip uninstall -umpy
command does not work since it thinks I am trying to pass an argument..
Does anybody know how to get rid of this package?
I have already tried various escapes:
>> py -m pip uninstall /-umpy
ERROR: Invalid requirement: '/-umpy'
>> py -m pip uninstall `-umpy
Usage:
C:\Program Files\Python35\python.exe -m pip uninstall [options] <package> ...
C:\Program Files\Python35\python.exe -m pip uninstall [options] -r <requirements file> ...
no such option: -u
>> py -m pip uninstall \-umpy
ERROR: Invalid requirement: '\\-umpy'
Hint: It looks like a path. File '\-umpy' does not exist.
>> py -m pip uninstall "-umpy"
Usage:
C:\Program Files\Python35\python.exe -m pip uninstall [options] <package> ...
C:\Program Files\Python35\python.exe -m pip uninstall [options] -r <requirements file> ...
no such option: -u
回答1:
Try
py -m pip uninstall -- -umpy
Double dashes separate options from non-options; used exactly in case like this.
BTW, I don't think -umpy
is a real package. It seems it's a leftover from an unsuccessful uninstallation of a package numpy
.
It could be you need to remove its directories manually. To do that, type py -m pip list -v
to get a list of all installed modules together with their installation location and then simply delete the corresponding folders.
回答2:
import subprocess
print((bytes(subprocess.check_output(['pip', 'uninstall', '-umpy'], stderr=subprocess.STDOUT)).decode()))
To automate it in a python script.
来源:https://stackoverflow.com/questions/57871371/unable-to-uninstall-package-named-umpy