pandas python pandas安装问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14106439/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
python pandas installation issues
提问by sgt pepper
I have tried installing from
我试过从安装
- source (
python setup.py installinto the extracted tar ball dir) - using
pip - using
easy_installbut nothing seems to work...I have downloaded and upgraded xcode, installed command-line tools..
- 源(
python setup.py install进入提取的焦油球目录) - 使用
pip - 使用
easy_install但似乎没有任何效果......我已经下载并升级了 xcode,安装了命令行工具..
I cloned the github repository for pandas
我为 Pandas 克隆了 github 存储库
cd ../pandas
python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to pandas.egg-info/requires.txt
writing pandas.egg-info/PKG-INFO
writing top-level names to pandas.egg-info/top_level.txt
writing dependency_links to pandas.egg-info/dependency_links.txt
reading manifest file 'pandas.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
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 '.DS_Store' found anywhere in distribution
writing manifest file 'pandas.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.6-intel/egg
running install_lib
running build_py
copying pandas/version.py -> build/lib.macosx-10.6-intel-2.7/pandas
running build_ext
**gcc-4.2 not found, using clang instead**
building 'pandas.index' extension
clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -Ipandas/src/klib -Ipandas/src -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c pandas/index.c -o build/temp.macosx-10.6-intel-2.7/pandas/index.o
In file included from pandas/index.c:260:
In file included from pandas/src/klib/khash_python.h:3:
pandas/src/klib/khash.h:573:1: warning: expression result unused [-Wunused-value]
KHASH_MAP_INIT_STR(str, size_t)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pandas/src/klib/khash.h:565:2: note: expanded from macro 'KHASH_MAP_INIT_STR'
KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_str_hash_func, kh_str_hash_equal)
^
---more output like that...and in the end
---更多这样的输出......最后
Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pandas-0.10.1.dev_c934e02-py2.7-macosx-10.6-intel.egg
Processing dependencies for pandas==0.10.1.dev-c934e02
Searching for pytz
Reading http://pypi.python.org/simple/pytz/
Reading http://pytz.sourceforge.net
Reading http://sourceforge.net/project/showfiles.php?group_id=79122
Reading http://www.stuartbishop.net/Software/pytz
Reading http://sourceforge.net/projects/pytz/
Best match: pytz 2012h
Downloading http://pypi.python.org/packages/2.7/p/pytz/pytz-2012h-py2.7.egg#md5=4258fcfc023e9ff0057405d935fc6e1d
Processing pytz-2012h-py2.7.egg
creating /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pytz-2012h-py2.7.egg
Extracting pytz-2012h-py2.7.egg to /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Adding pytz 2012h to easy-install.pth file
Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pytz-2012h-py2.7.egg
-----
Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/six-1.2.0-py2.7.egg
Searching for numpy==1.6.2
Best match: numpy 1.6.2
Adding numpy 1.6.2 to easy-install.pth file
Using /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Finished processing dependencies for pandas==0.10.1.dev-c934e02
ipython
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43)
Type "copyright", "credits" or "license" for more information.
IPython 0.14.dev -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import pandas
seems to work without issues..
似乎工作没有问题..
when i use easy_install to install pandas, the on-screen output seems to suggest that it worked but on loading, python is not able to find the library
当我使用 easy_install 安装 pandas 时,屏幕输出似乎表明它可以工作,但在加载时,python 无法找到该库
sudo easy_install pandas
Searching for pandas
Best match: pandas 0.10.1.dev-c934e02
Processing pandas-0.10.1.dev_c934e02-py2.7-macosx-10.8-intel.egg
pandas 0.10.1.dev-c934e02 is already the active version in easy-install.pth
Using /usr/local/lib/python2.7/site-packages/pandas-0.10.1.dev_c934e02-py2.7-macosx-10.8-intel.egg
Processing dependencies for pandas
Finished processing dependencies for pandas
dekumar-mn:ipython dekumar$ python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pandas
回答by abarnert
You have multiple versions of Python 2.7. You installed pandasfor one version, and then tried to import it into the other, and you can't do that, because they have separate site libraries.
您有多个 Python 2.7 版本。您安装pandas了一个版本,然后尝试将其导入另一个版本,但您不能这样做,因为它们具有单独的站点库。
If you need multiple versions of Python 2.7 for some reason, you have to learn how to manage multiple versions of Python. For example, always be sure whether you're using /usr/bin/easy_installor /usr/local/bin/easy_install, and use the one that goes with the pythonyou plan to run.
如果出于某种原因需要多个版本的 Python 2.7,则必须学习如何管理多个版本的 Python。例如,始终确定您使用的是/usr/bin/easy_install或/usr/local/bin/easy_install,并使用与python您计划运行的程序配套的那个。
But you probably don't need multiple versions. If you just uninstall the non-Apple one, everything will be a lot easier.
但是您可能不需要多个版本。如果你只是卸载非苹果的,一切都会容易得多。
You can figure out the details from the paths in your logs. The manual install went to /Library/Python/2.7/site-packages, which is where Apple's /usr/bin/pythonlooks. But the easy_installwent to /usr/local/lib/python/2.7/site-packages, which is where the third-party (presumably Homebrew, from the brewtag?) /usr/local/bin/python. So clearly, the first pythonon your path is /usr/bin/python, while the first easy_installis /usr/local/bin/easy_install. That's going to lead to confusion, as it did here.
您可以从日志中的路径中找出详细信息。手动安装转到/Library/Python/2.7/site-packages,这就是 Apple 的/usr/bin/python样子。但是easy_install转到/usr/local/lib/python/2.7/site-packages,这是第三方(大概是 Homebrew,来自brew标签?)的地方/usr/local/bin/python。很明显,python您路径上/usr/bin/python的第一个easy_install是,而第一个是/usr/local/bin/easy_install。这将导致混乱,就像这里所做的那样。
Even worse, if you install ipythoninto both Pythons, whichever one you install second is going to end up as /usr/local/bin/ipython, which is going to lead to even moreconfusion.
更糟糕的是,如果您同时安装ipython到两个 Python 中,那么您第二次安装的任何一个最终都会变成/usr/local/bin/ipython,这将导致更多的混乱。
If you do sudo /usr/bin/easy_install pandas, you can use pandasin the Apple Python. To make sure that's the one you run, always do /usr/bin/pythonor /usr/bin/python /usr/local/bin/ipython. If you do sudo /usr/local/bin/easy_install pandas, you can use pandasin the third-party Python. To make sure that's the one you run, always do /usr/local/bin/pythonor /usr/local/bin/python /usr/local/bin/ipython.
如果你这样做sudo /usr/bin/easy_install pandas,你可以pandas在 Apple Python 中使用。为确保您运行的是那个,请始终执行/usr/bin/python或/usr/bin/python /usr/local/bin/ipython。如果这样做sudo /usr/local/bin/easy_install pandas,则可以pandas在第三方 Python 中使用。为确保您运行的是那个,请始终执行/usr/local/bin/python或/usr/local/bin/python /usr/local/bin/ipython。
Looking at your comments, and your more detailed edit, it's possible that you actually have twothird-party Pythons here, which makes things even more confusing. If both of them prefer /usr/local/bin(and unless you're using MacPorts or Fink, they do), you've probably got one of them half-overwritten by the other, and there's just no way you're going to get this working. If that's the case, I would recommend that you do something radical. If you're not willing to do an install-from-scratch-with-settings-import of OS X, at least rm -rf /usr/local /Library/Python ~/Library/Python, then reinstall brewand any other third-party stuff you need, and this time make sure to only install one extra Python (although zero would still be better!).
查看您的评论和更详细的编辑,您可能实际上在这里有两个第三方 Python,这让事情变得更加混乱。如果他们都喜欢/usr/local/bin(除非您使用的是 MacPorts 或 Fink,否则他们会这样做),您可能已经将其中一个覆盖了一半,而且您根本无法使其正常工作。如果是这样的话,我建议你做一些激进的事情。如果你不愿意从头开始安装 OS X,至少rm -rf /usr/local /Library/Python ~/Library/Python,然后重新安装brew你需要的任何其他第三方的东西,这次确保只安装一个额外的 Python (虽然零仍然会更好!)。
Meanwhile, two minor side notes:
同时,两个次要的旁注:
It's almost always better to use
pipthaneasy_install. If you don't have it,sudo easy_install pip, and now you do. (The only common exceptions to that "almost" are forpipitself, and forreadline.)Don't use
sudowith Homebrew. Homebrew goes through a lot of trouble to set up all of the directories it touches so you never needsudo. Once you start doingsudo brew,sudo /usr/local/bin/easy_install, etc., you end up breaking that, so later installations get permissions errors, and it takes a lot of work withbrew doctorto fix everything.
使用它几乎总是
pip比easy_install. 如果你没有它,sudo easy_install pip现在你有了。(“几乎”的唯一常见例外是对于pip它自己和对于readline。)不要
sudo与 Homebrew 一起使用。Homebrew 在设置它涉及的所有目录时遇到了很多麻烦,因此您永远不需要sudo. 一旦您开始执行sudo brew、sudo /usr/local/bin/easy_install等,您最终会破坏它,因此以后的安装会出现权限错误,并且需要大量工作brew doctor才能修复所有内容。

