简体   繁体   English

在Mac OS X上安装熊猫:ImportError(无法导入名称哈希表)

[英]Pandas installation on Mac OS X: ImportError (cannot import name hashtable)

I would like to build pandas from source rather than use a package manager because I am interested in contributing. 我想从源头上构建熊猫,而不是使用包管理器,因为我有兴趣为之贡献。 The first time I tried to build pandas, these were the steps I took: 第一次尝试建立熊猫时,采取了以下步骤:

1) created the virtualenv mkvirtualenv --no-site-packages pandas 1)创建了virtualenv mkvirtualenv --no-site-packages pandas

2) activated the virtualenv 2)激活virtualenv

3) installed Anaconda CE. 3)安装了Anaconda CE。 However, this was installed in ~/anaconda. 但是,它安装在〜/ anaconda中。

4) cloned pandas 4)克隆熊猫

5) built C extensions in place 5)内置C扩展

(pandas)ems ~/.virtualenvs/pandas/localrepo/pandas> ~/anaconda/bin/python setup.py build_ext --inplace

6) built pandas 6)建造熊猫

(pandas)ems ~/.virtualenvs/pandas/localrepo/pandas> ~/anaconda/bin/python setup.py build

7) ran nosetests on master branch 7)在主分支上进行鼻子测试

Tests failed: (pandas)ems ~/.virtualenvs/pandas/localrepo/pandas> nosetests pandas E ====================================================================== ERROR: Failure: ValueError (numpy.dtype has the wrong size, try recompiling) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/EmilyChen/.virtualenvs/pandas/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName addr.filename, addr.module) File "/Users/EmilyChen/.virtualenvs/pandas/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath return self.importFromDir(dir_path, fqname) File "/Users/EmilyChen/.virtualenvs/pandas/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir mod = load_module(part_fqname, fh, filename, desc) File "/Users/EmilyChen/.virtualenvs/pandas/localrepo/pandas/pandas/ init .py", line 6, in from . 测试失败:(pandas)ems〜/ .virtualenvs / pandas / localrepo / pandas>鼻子测试熊猫E =========================== ========================================错误:失败:ValueError(numpy.dtype大小错误,请尝试重新编译)------------------------------------------ ----------------------------追溯(最近一次通话最近):文件“ /Users/EmilyChen/.virtualenvs/pandas/lib/ python2.7 / site-packages / nose / loader.py”,第390行,位于loadTestsFromName addr.filename,addr.module)文件“ /Users/EmilyChen/.virtualenvs/pandas/lib/python2.7/site-packages/ “ nose / importer.py”,在importFromPath中的第39行,返回self.importFromDir(dir_path,fqname)文件“ /Users/EmilyChen/.virtualenvs/pandas/lib/python2.7/site-packages/nose/importer.py”,第86行,位于importFromDir mod = load_module(part_fqname,fh,文件名,desc)文件“ /Users/EmilyChen/.virtualenvs/pandas/localrepo/pandas/pandas/ init .py”中,第6行,来自。 import hashtable, tslib, lib File "numpy.pxd", line 156, in init pandas.hashtable (pandas/hashtable.c:20354) ValueError: numpy.dtype has the wrong size, try recompiling 在初始pandas.hashtable(pandas / hashtable.c:20354)中,导入哈希表,tslib,lib文件“ numpy.pxd”,第156行,ValueError:numpy.dtype的大小错误,请尝试重新编译


Ran 1 test in 0.001s 在0.001秒内进行1次测试

FAILED (errors=1) 失败(错误= 1)

Someone on the PyData mailing list said: PyData邮件列表上的某人说:

It looks like you have NumPy installed someplace else on your machine and AnacondaCE is not playing nicely in the virtualenv. 看来您在计算机上的其他位置安装了NumPy,而AnacondaCE在virtualenv中的播放效果也不佳。 The error you are getting is a Cython error message which occurs when the NumPy version it built against doesn't match the installed version on your system-- I had thought that 1.7.x was supposed to be ABI compatible with 1.6.x (so this would not happen) but I guess not. 您收到的错误是Cython错误消息,当它针对其构建的NumPy版本与您系统上的已安装版本不匹配时,会发生此错误-我以为1.7.x应该与1.6.x兼容,所以这不会发生),但我想不会。 Sigh

The numpy version in Anaconda CE library is 1.7.0b2 and my system numpy installation is version 1.5.1. Anaconda CE库中的numpy版本是1.7.0b2,而我的系统numpy安装的版本是1.5.1。 Setup.py linked to the numpy in the Anaconda distribution's libraries when it built pandas but my guess is it's linking to my system version when nosetests runs /pandas/ init .py Setup.py在构建熊猫时链接到Anaconda发行版库中的numpy,但我猜测是当鼻子测试运行/ pandas / init .py时,它链接到我的系统版本。

Next , I repeated the steps outside a virtualenv, but got the same error. 接下来 ,我在virtualenv之外重复了这些步骤,但是遇到了同样的错误。 Finally , I decided to install all the dependencies in a new virtualenv instead of using the Anaconda distribution to build pandas. 最后 ,我决定将所有依赖项安装在新的virtualenv中,而不是使用Anaconda发行版来构建熊猫。 This way, I can see that dependencies like numpy reside in the lib directory of the virtualenv python installation, which takes precedent when pandas. 这样,我可以看到像numpy这样的依赖项驻留在virtualenv python安装的lib目录中,当熊猫使用时,该目录优先。 init runs import statements. init运行导入语句。 This is what I did: 这是我所做的:

1) installed numpy, dateutil, pytz, cython, scipy, matplotlib and openpyxl using pip 1)使用pip安装numpy,dateutil,pytz,cython,scipy,matplotlib和openpyxl

2) built c extensions in place 2)内置c扩展

3) pandas install output here: http://pastebin.com/3CKf1f9i 3)熊猫在此处安装输出: http : //pastebin.com/3CKf1f9i

4) pandas did not install correctly 4)熊猫未正确安装

(pandas)ems ~/.virtualenvs/pandas/localrepo/pandas> python
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
 cannot import name hashtable
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pandas/__init__.py", line 6, in <module>
from . import hashtable, tslib, lib
ImportError: cannot import name hashtable

I took a look at this question but cython installed in my case, and I am trying to build successfully from source rather than using pip like the answer recommended.. 我看了一下这个问题,但是在我的情况下安装了cython,我正在尝试从源代码成功构建,而不是像建议的答案那样使用pip。

(pandas)ems ~/.virtualenvs/pandas/localrepo/pandas> which cython
/Users/EmilyChen/.virtualenvs/pandas/bin/cython

I've received the same error ( ImportError: cannot import name hashtable ) when trying to import pandas from the source code directory. 尝试从源代码目录导入熊猫时,我收到了相同的错误( ImportError: cannot import name hashtable )。 Try starting the python interpreter from a different directory and import pandas again. 尝试从其他目录启动python解释器,然后再次导入pandas。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM