24

我在我的 Mac OSX 计算机上安装 Python Pandas 库时遇到问题。

我在终端中输入以下内容:

$ sudo easy_install pandas

但后来我得到以下信息:

Searching for pandas
Reading http://pypi.python.org/simple/pandas/
Reading http://pandas.pydata.org
Reading http://pandas.sourceforge.net
Best match: pandas 0.9.0
Downloading http://pypi.python.org/packages/source/p/pandas/pandas-
0.9.0.zip#md5=04b1d8e11cc0fc30ae777499d89003ec
Processing pandas-0.9.0.zip
Writing /tmp/easy_install-ixjbQO/pandas-0.9.0/setup.cfg
Running pandas-0.9.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ixjbQO/pandas-
0.9.0/egg-dist-tmp-EGREoT
warning: no files found matching 'setupegg.py'
no previously-included directories found matching 'doc/build'
warning: no previously-included files matching '*.so' found anywhere in distribution
warning: no previously-included files matching '*.pyd' found anywhere in distribution
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '.git*' found anywhere in distribution
warning: no previously-included files matching '.DS_Store' found anywhere in distribution
warning: no previously-included files matching '*.png' found anywhere in distribution
unable to execute gcc: No such file or directory
error: Setup script exited with error: command 'gcc' failed with exit status 1

我确实安装了 Xcode 和 gcc,但是,只有在我键入时才会找到 gcc:

$ gcc
-bash: gcc: command not found

$ gcc-4.2
i686-apple-darwin11-gcc-4.2.1: no input files

我应该怎么办?

4

13 回答 13

42

安装pip.

然后pandas安装pip

pip install pandas
于 2014-02-08T17:30:51.643 回答
17

您可以使用自制软件安装 python:

brew install python

确保 OSX 使用正确的路径:

which python

然后就可以使用pip工具安装pandas了:

pip install pandas

确保安装了所有依赖项。我遵循了本教程: http: //penandpants.com/2013/04/04/install-scientific-python-on-mac-os-x/

在我的机器上工作正常。

于 2014-04-03T20:36:36.473 回答
9

您需要安装 XCode 并且需要确保为 XCode 安装命令行工具,以便获得 gcc。

于 2012-11-06T14:09:43.830 回答
8

尝试

pip3 install pandas 

从终端。也许您原来的 pip install pandas 正在引用 anaconda 发行版

于 2017-12-05T22:49:17.053 回答
4

我会推荐使用 macport 或 fink 来安装 pandas:

  1. 从 App Store 安装 XCode,这将安装 3 个编译器,clang、gcc ("apple") 和 gcc ("normal")
  2. 安装 macports (www.macports.org) 或 fink (www.finkproject.org)
  3. 永远不要再次使用你的 mac python,并通过 fink/macport 安装所有 python 模块,并享受它为你照顾依赖关系。

在 macports 中安装 pandas 很简单: sudo port install py27-pandas

你通常在 /opt/local 中安装 macport,在 /sw 中安装 fink,我建议(尽管这可能是个坏建议)你将你的 fink/mac 端口 python 符号链接到你的系统 python,如下所示:/usr/bin/python -> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

于 2012-11-06T11:30:50.547 回答
4

在 Mac 终端中(我们可以通过在 Spotlight 搜索Command + 空格中搜索来启动 Mac终端)现在,使用以下命令:

pip3 安装熊猫

由于我使用的是Python 版本 3,我需要使用 pip3 install pandas。

如果您使用的是python 版本 2 ,则使用命令:

点安装熊猫

确保pip已安装在设备中

于 2019-07-05T18:47:59.927 回答
2

pip install pandaspip 18.0与on一起工作正常macOS 10.13.6。此外,要使用 Xlsx 文件,您需要xlrd安装。

于 2018-09-19T19:27:03.670 回答
1

这不是一种创新方式,但以下两个步骤可能会节省大量时间和精力。

  1. 更新(安装命令行工具)代码。

这可以通过 openinig XCode -> Menu -> Preference -> Components -> Command Line Tool 来完成

  1. 删除除 Python 2.7 之外的所有内容

我确实在不同的时间安装了不同的 python 实例,除 2.7 之外的所有实例对我来说都是有帮助的。注意:您可能必须在完成后安装模块。所以准备好使用 pip/easy_install/ports。

卸载可以通过以下链接中提到的超级简单步骤完成。

如何在 Mac OS X 10.6.4 上卸载 Python 2.7?

于 2013-02-06T06:30:56.150 回答
0

我相信你需要一个 sim 链接

$ ln -s gcc gcc-4.2

这应该告诉您的终端在您运行 $ gcc 时调用 gcc-4.2。

于 2013-09-13T17:26:14.390 回答
0

对于 Mac 在终端中运行给定的命令

sudo easy_install pip
pip3 install pandas

如果你想安装 pandas 分析然后运行

pip3 install pandas-profiling
于 2021-07-21T10:30:06.183 回答
0

写下这个并尝试再次导入熊猫!

import sys
!{sys.executable} -m pip install pandas

它对我有用,希望对你也有用。

于 2021-02-09T21:37:32.067 回答
0

您需要从 appStore 安装最新版本的 xCode。它包含适用于 mac 的 C(gcc) 和 C++(g++) 的编译器。然后你就可以毫无问题地安装 pandas 了。在终端中使用以下命令:

  1. xcode-选择--安装

  2. pip3 安装熊猫

它也安装其他软件包可能需要一些时间。请耐心等待。

于 2019-10-17T09:41:57.020 回答
-1

pip install 对我有用,但由于权限问题而失败,当我使用时已解决

sudo pip 安装熊猫

我看到最好的 sudo 解决方法来自 /tmp:在 sudo 下运行 pip install 是否可以接受且安全?

于 2016-12-03T03:20:37.930 回答