如何卸载所有 python 个软件包

how to uninstall all python packages

我刚刚更新了 numpymatplotlib 和最新版本的 numpy 似乎有冲突。我有 matplotlib 1.1.1rc。我尝试使用以下命令升级 matplotlib

sudo pip install --upgrade matplotlib

我收到以下警告:

The directory '/home/po/.cache/pip/http' or its parent directory is not owned by 
the current user and the cache has been disabled. Please check the permissions and
owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

包已下载并安装,在过程结束时我收到以下信息:

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-yq3kB5/matplotlib

我正在考虑卸载所有软件包,然后重新安装。有没有快速的方法来做到这一点?

编辑 1

我在终端中写道:

sudo -H pip install -U matplotlib

我得到以下信息:

/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Collecting matplotlib
  Downloading matplotlib-1.5.0.tar.gz (54.0MB)
    100% |████████████████████████████████| 54.0MB 7.3kB/s 
    Complete output from command python setup.py egg_info:
    ============================================================================
    Edit setup.cfg to change the build options`

    BUILDING MATPLOTLIB
                matplotlib: yes [1.5.0]
                    python: yes [2.7.3 (default, Jun 22 2015, 19:33:41)  [GCC
                            4.6.3]]
                  platform: yes [linux2]

    REQUIRED DEPENDENCIES AND EXTENSIONS
                     numpy: yes [version 1.10.1]
                  dateutil: yes [using dateutil version 2.4.2]
                      pytz: yes [using pytz version 2015.7]
                    cycler: yes [cycler was not found. pip will attempt to
                            install it after matplotlib.]
                   tornado: yes [using tornado version 4.2.1]
                 pyparsing: yes [matplotlib requires pyparsing >= 1.5.6]
                    libagg: yes [pkg-config information for 'libagg' could not
                            be found. Using local copy.]
                  freetype: no  [The C/C++ header for freetype2 (ft2build.h)
                            could not be found.  You may need to install the
                            development package.]
                       png: yes [version 1.2.46]
                     qhull: yes [pkg-config information for 'qhull' could not be
                            found. Using local copy.]

    OPTIONAL SUBPACKAGES
               sample_data: yes [installing]
                  toolkits: yes [installing]
                     tests: yes [using nose version 1.1.2 / mock is required to
                            run the matplotlib test suite. "setup.py test" will
                            automatically download it. Install mock to run
                            matplotlib.test()]
            toolkits_tests: yes [using nose version 1.1.2 / mock is required to
                            run the matplotlib test suite. "setup.py test" will
                            automatically download it. Install mock to run
                            matplotlib.test()]

    OPTIONAL BACKEND EXTENSIONS
                    macosx: no  [Mac OS-X only]
                    qt5agg: no  [PyQt5 not found]
                    qt4agg: yes [installing, Qt: 4.8.1, PyQt: 4.8.1; PySide not
                            found]
                   gtk3agg: yes [installing, version 3.2.4]
                 gtk3cairo: yes [installing, version 3.2.4]
                    gtkagg: no  [The C/C++ header for gtk (gtk/gtk.h) could not
                            be found.  You may need to install the development
                            package.]
                     tkagg: no  [The C/C++ header for Tk (tk.h) could not be
                            found.  You may need to install the development
                            package.]
                     wxagg: no  [requires wxPython]
                       gtk: no  [The C/C++ header for gtk (gtk/gtk.h) could not
                            be found.  You may need to install the development
                            package.]
                       agg: yes [installing]
                     cairo: yes [installing, pycairo version 1.8.8]
                 windowing: no  [Microsoft Windows only]

    OPTIONAL LATEX DEPENDENCIES
                    dvipng: yes [version 1.14]
               ghostscript: yes [version 9.05]
                     latex: yes [version 3.1415926]
                   pdftops: yes [version 0.18.4]

    OPTIONAL PACKAGE DATA
                      dlls: no  [skipping due to configuration]

    ============================================================================
                            * The following required packages can not be built:
                            * freetype

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-elVWaU/matplotlib
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning

但是当我关闭 python 时,仍然重新加载它,然后写:

import matplotlib

matplotlib.__version__

我得到1.1.1rc

终于成功了,这是我所做的:

首先,我使用以下命令卸载了 matplotlib:

sudo apt-get remove python-matplotlib

然后,由于pip没有安装系统级依赖,我使用命令下载了freetype

apt-get install libfreetype6-dev

然后,我使用命令

重新安装了matplotlib
sudo -H pip install matplotlib

注意: 我猜 uninstallingreinstalling matplotlib 是没有意义的。我本可以先安装 freetype 然后升级 matplotlib 使用:

sudo -H pip install -U matplotlib