gpt4 book ai didi

python pandas 安装问题

转载 作者:行者123 更新时间:2023-11-28 20:49:38 24 4
gpt4 key购买 nike

我试过从

安装
  1. 源代码(python setup.py install 到提取的 tar ball 目录中)
  2. 使用 pip
  3. 使用 easy_install 但似乎没有任何效果...我已经下载并升级了 xcode,安装了命令行工具..

我克隆了 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)
^

---更多类似的输出......最后

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

似乎工作没有问题..

当我使用 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

最佳答案

您有多个版本的 Python 2.7。您为一个版本安装了 pandas,然后尝试将其导入另一个版本,但您不能这样做,因为它们有单独的站点库。

如果出于某种原因需要多个版本的 Python 2.7,则必须学习如何管理多个版本的 Python。例如,始终确定您使用的是 /usr/bin/easy_install 还是 /usr/local/bin/easy_install,并使用与 python 你打算运行。

但您可能不需要多个版本。如果你只是卸载非苹果的,一切都会简单很多。

您可以从日志中的路径中找出详细信息。手动安装到 /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。这会导致混淆,就像这里所做的那样。

更糟糕的是,如果你将 ipython 安装到两个 Python 中,你安装第二个的那个将以 /usr/local/bin/ipython 结束,这是会导致更多困惑。

如果你执行 sudo/usr/bin/easy_install pandas,你可以在 Apple Python 中使用 pandas。为确保这是您运行的那个,请始终执行 /usr/bin/python/usr/bin/python/usr/local/bin/ipython。如果你执行 sudo/usr/local/bin/easy_install pandas,你可以在第三方 Python 中使用 pandas。为确保这是您运行的那个,请始终执行 /usr/local/bin/python/usr/local/bin/python/usr/local/bin/ipython .

查看您的评论和更详细的编辑,您实际上可能有 两个 第三方 Python,这让事情变得更加困惑。如果他们都喜欢 /usr/local/bin(除非你使用 MacPorts 或 Fink,他们喜欢),你可能已经将其中一个覆盖了一半,并且有只是您无法使它正常工作。如果是这样的话,我会建议你做一些激进的事情。如果您不愿意从头开始安装并导入 OS X,至少 rm -rf/usr/local/Library/Python ~/Library/Python,然后重新安装 brew 和你需要的任何其他第三方东西,这次确保只安装一个额外的 Python(尽管零仍然会更好!)。

与此同时,两个小的旁注:

  1. 使用 pip 几乎总是比使用 easy_install 更好。如果您没有,sudo easy_install pip,现在您有了。 (“几乎”的唯一常见异常(exception)是 pip 本身和 readline。)

  2. 不要在 Homebrew 中使用 sudo。 Homebrew 经历了很多麻烦来设置它涉及的所有目录,因此您永远不需要 sudo。一旦你开始执行 sudo brewsudo/usr/local/bin/easy_install 等,你最终会破坏它,所以以后的安装会出现权限错误,并且需要与 brew doctor 进行大量工作以解决所有问题。

关于python pandas 安装问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14106439/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com