为什么 Seaborn 无法在 PyCharm 或命令行上安装?

为什么 Seaborn 无法在 PyCharm 或命令行上安装?

当我尝试通过将包添加到我的可用包中来在 PyCharm 中安装 seaborn 时,我收到一条错误消息,指出

非零退出代码(1)

它提出了如下解决方案:

尝试pip install seaborn从系统终端运行此命令 ( )。确保您使用位于“/usr/bin/python2.7”的 Python 解释器安装的正确版本的“pip”。

当我在终端中运行命令时收到以下错误:

命令“python setup.py egg_info”在 /tmp/pip-build-edImGe/matplotlib 中失败,错误代码为 1

完整的终端如下所示:

calflan@calflan-MacBookPro:~/Projects/CIS3303$ pip install seaborn
You are using pip version 7.1.0, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.                                                          
Collecting seaborn
  Downloading seaborn-0.7.1.tar.gz (158kB)
    100% |████████████████████████████████| 159kB 2.1MB/s 
Collecting scipy (from seaborn)
  Downloading scipy-0.18.1.tar.gz (13.1MB)
    100% |████████████████████████████████| 13.1MB 48kB/s 
Collecting matplotlib (from seaborn)
  Using cached matplotlib-1.5.3.tar.gz
    Complete output from command python setup.py egg_info:
    IMPORTANT WARNING:
        pkg-config is not installed.
        matplotlib may not be able to find some of its dependencies
============================================================================
Edit setup.cfg to change the build options

BUILDING MATPLOTLIB
            matplotlib: yes [1.5.3]
                python: yes [2.7.12 (default, Jul  1 2016, 15:12:24)  [GCC
                        5.4.0 20160609]]
              platform: yes [linux2]

REQUIRED DEPENDENCIES AND EXTENSIONS
                 numpy: yes [version 1.11.0]
              dateutil: yes [using dateutil version 2.6.0]
                  pytz: yes [using pytz version 2016.7]
                cycler: yes [cycler was not found. pip will attempt to
                        install it after matplotlib.]
               tornado: yes [tornado was not found. It is required for the
                        WebAgg backend. pip/easy_install may attempt to
                        install it after matplotlib.]
             pyparsing: yes [pyparsing was not found. It is required for
                        mathtext support. pip/easy_install may attempt to
                        install it after matplotlib.]
                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.54]
                 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 [nose 0.11.1 or later is required to run the
                        matplotlib test suite. Please install it with pip or
                        your preferred tool to run the test suite / mock is
                        required to run the matplotlib test suite. Please
                        install it with pip or your preferred tool to run
                        the test suite]
        toolkits_tests: yes [nose 0.11.1 or later is required to run the
                        matplotlib test suite. Please install it with pip or
                        your preferred tool to run the test suite / mock is
                        required to run the matplotlib test suite. Please
                        install it with pip or your preferred tool to run
                        the test suite]

OPTIONAL BACKEND EXTENSIONS
                macosx: no  [Mac OS-X only]
                qt5agg: no  [PyQt5 not found]
                qt4agg: yes [installing, Qt: 4.8.7, PyQt: 4.8.7; PySide not
                        found]
               gtk3agg: no  [Requires gtk3 development files to be
                        installed.]
             gtk3cairo: no  [Requires gtk3 development files to be
                        installed.]
                gtkagg: no  [The C/C++ header for gtk (gtk/gtk.h) could not
                        be found.  You may need to install the development
                        package.]
                 tkagg: yes [installing; run-time loading from Python Tcl /
                        Tk]
                 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: no
           ghostscript: yes [version 9.18]
                 latex: no
               pdftops: yes [version 0.41.0]

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-edImGe/matplotlib

该日志的顶部显示以下内容:

您使用的是 pip 版本 7.1.0,但可以使用版本 9.0.1。您应该考虑通过“pip install --upgrade pip”命令进行升级。

因此我尝试使用以下命令升级 pip:pip install --upgrade pip但产生了更多错误,如下所示:

calflan@calflan-MacBookPro:~/Projects/CIS3303$ pip install --upgrade pip

You are using pip version 7.1.0, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pip
  Using cached pip-9.0.1-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 7.1.0
    Uninstalling pip-7.1.0:
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip-7.1.0-py2.7.egg/pip/basecommand.py", line 223, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/pip-7.1.0-py2.7.egg/pip/commands/install.py", line 299, in run
    root=options.root_path,
  File "/usr/local/lib/python2.7/dist-packages/pip-7.1.0-py2.7.egg/pip/req/req_set.py", line 640, in install
    requirement.uninstall(auto_confirm=True)
  File "/usr/local/lib/python2.7/dist-packages/pip-7.1.0-py2.7.egg/pip/req/req_install.py", line 726, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/usr/local/lib/python2.7/dist-packages/pip-7.1.0-py2.7.egg/pip/req/req_uninstall.py", line 125, in remove
    renames(path, new_path)
  File "/usr/local/lib/python2.7/dist-packages/pip-7.1.0-py2.7.egg/pip/utils/__init__.py", line 314, in renames
    shutil.move(old, new)
  File "/usr/lib/python2.7/shutil.py", line 300, in move
    rmtree(src)
  File "/usr/lib/python2.7/shutil.py", line 247, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "/usr/lib/python2.7/shutil.py", line 252, in rmtree
    onerror(os.remove, fullname, sys.exc_info())
  File "/usr/lib/python2.7/shutil.py", line 250, in rmtree
    os.remove(fullname)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pip-7.1.0-py2.7.egg/EGG-INFO/requires.txt'

我做错了什么以及我必须做什么才能安装 Seaborn?

答案1

这里的问题是需要更新 'pip' 版本,但正常的命令pip install --upgrade pip不起作用。可以使用 卸载 'pip' 来解决sudo pip uninstall pip

完成后,使用以下命令重新安装“pip”:

sudo apt-get install python-setuptools python-dev build essential

其次是:

sudo easy_install pip

现在,您已成功重新安装“pip”(现在是升级形式),您可以使用以下命令安装“Seaborn”:

pip install seaborn

来源:http://www.saltycrane.com/blog/2010/02/how-install-pip-ubuntu/

忽略最后一步,因为不需要(安装虚拟环境)

相关内容