我希望从源代码构建熊猫,而不是使用包管理器,因为我有兴趣贡献。我第一次尝试建立熊猫时,采取了以下步骤:
1)创建了virtualenv
mkvirtualenv --no-site-packages pandas
2)激活virtualenv
3)安装水蟒CE。不过,这是安装在~/anaconda中的。
4)克隆大熊猫
5)在适当位置建造C延伸
(pandas)ems ~/.virtualenvs/pandas/localrepo/pandas> ~/anaconda/bin/python setup.py build_ext --inplace
6)大熊猫
(pandas)ems ~/.virtualenvs/pandas/localrepo/pandas> ~/anaconda/bin/python setup.py build
7)对主分支进行鼻测试
测试失败:
(熊猫)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”,第39行,在importFromPath中
返回self.importFromDir(目录路径,fqname)
文件“/Users/EmilyChen/.virtualenvs/pandas/lib/python2.7/site packages/nose/importer.py”,第86行,importFromDir
mod=加载模块(部分fqname,fh,filename,desc)
文件“/Users/EmilyChen/.virtualenvs/pandas/localrepo/pandas/pandas/init.py”,第6行,在
从。导入哈希表,tslib,lib
文件“numpy.pxd”,第156行,在init pandas.hashtable(pandas/hashtable.c:20354)中
值错误:numpy.dtype的大小错误,请尝试重新编译
在0.001s内运行1个测试
失败(错误=1)
PyData邮件列表上有人说:It looks like you have NumPy installed someplace else on your machine and AnacondaCE is not playing nicely in the 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. Sigh
Anaconda CE库中的numpy版本是1.7.0b2,我的系统numpy安装版本是1.5.1。Setup.py在创建pandas时链接到了Anaconda发行版库中的numpy,但我猜它是在notests运行时链接到了我的系统版本/pandas/in it.py
接下来,我在virtualenv之外重复了这些步骤,但得到了相同的错误。最后,我决定在一个新的virtualenv中安装所有依赖项,而不是使用Anaconda发行版来构建熊猫。这样,我可以看到像numpy这样的依赖项驻留在virtualenv python安装的lib目录中,这在pandas运行import语句时是先例。我就是这么做的:
1)使用pip安装了numpy、dateutil、pytz、cython、scipy、matplotlib和openpyxl
2)在适当位置建造c延伸
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 "", line 1, in
File "pandas/__init__.py", line 6, in
from . import hashtable, tslib, lib
ImportError: cannot import name hashtable
我看了一下this question但是cython安装在我的案例中,我试图从源代码成功构建,而不是像建议的那样使用pip。。(pandas)ems ~/.virtualenvs/pandas/localrepo/pandas> which cython
/Users/EmilyChen/.virtualenvs/pandas/bin/cython