【问题标题】:Any way to install Pandas with PyPy?有什么方法可以用 PyPy 安装 Pandas?
【发布时间】:2017-01-22 20:38:49
【问题描述】:

我正在尝试使用 PyPy 运行一些代码以加快速度。我的代码使用 Pandas 数据框,所以我正在尝试找到一种安装包的方法...

不幸的是,我找不到这样做的方法...在网上搜索会得到 thisthis -- 两个令人失望的结果表明这是不可能的,但它们是 1-2 岁的!

this twitter post from Romain Guillebert 带来了一线希望,这表明我可以使用名为 pymetabiosis 的包来做到这一点。不幸的是,当我去安装它时,我收到了下面提到的错误。

知道如何调试错误或找到其他将 Pandas 与 PyPy 结合使用的方法?**


安装 pymetabiosis 时出现错误消息:
Collecting pymetabiosis
  Using cached pymetabiosis-0.0.1.tar.gz
    Complete output from command python setup.py egg_info:
    pymetabiosis/__pycache__/_cffi__x771a6f66x197b9d2b.c:219:13: warning: initializing 'char **' with an expression of type 'const char **' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers]
      { char * *tmp = &p->ml_name; (void)tmp; }
                ^     ~~~~~~~~~~~
    pymetabiosis/__pycache__/_cffi__x771a6f66x197b9d2b.c:220:13: warning: incompatible pointer types initializing 'void **' with an expression of type 'PyCFunction *' (aka 'struct _object *(**)(struct _object *, struct _object *)') [-Wincompatible-pointer-types]
      { void * *tmp = &p->ml_meth; (void)tmp; }
                ^     ~~~~~~~~~~~
    pymetabiosis/__pycache__/_cffi__x771a6f66x197b9d2b.c:222:13: warning: initializing 'char **' with an expression of type 'const char **' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers]
      { char * *tmp = &p->ml_doc; (void)tmp; }
                ^     ~~~~~~~~~~
    pymetabiosis/__pycache__/_cffi__x771a6f66x197b9d2b.c:1189:30: warning: incompatible pointer types passing 'PyObject *' (aka 'struct _object *') to parameter of type 'PyCodeObject *' [-Wincompatible-pointer-types]
      { result = PyEval_EvalCode(x0, x1, x2); }
                                 ^~
    //anaconda/include/python2.7/eval.h:10:54: note: passing argument to parameter here
    PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyCodeObject *, PyObject *, PyObject *);
                                                         ^
    pymetabiosis/__pycache__/_cffi__x771a6f66x197b9d2b.c:1857:12: warning: incompatible integer to pointer conversion assigning to 'PyObject *' (aka 'struct _object *') from 'int' [-Wint-conversion]
      { result = PyObject_SetAttr(x0, x1, x2); }
               ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    pymetabiosis/__pycache__/_cffi__x771a6f66x197b9d2b.c:2164:5: warning: incompatible pointer types assigning to 'PyObject *(*)(size_t, ...)' (aka 'struct _object *(*)(unsigned long, ...)') from 'PyObject *(Py_ssize_t, ...)' (aka 'struct _object *(long, ...)') [-Wincompatible-pointer-types]
      i = (PyTuple_Pack);
        ^ ~~~~~~~~~~~~~~
    6 warnings generated.
    ld: warning: directory not found for option '-L//anaconda/lib
    '
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/t4/n42mh55n05sd6s5hgk1dzdz80000gp/T/pip-build-fSTXPd/pymetabiosis/setup.py", line 2, in <module>
        from pymetabiosis.bindings import ffi
      File "pymetabiosis/__init__.py", line 1, in <module>
        from pymetabiosis.module import import_module
      File "pymetabiosis/module.py", line 2, in <module>
        from pymetabiosis.wrapper import MetabiosisWrapper
      File "pymetabiosis/wrapper.py", line 3, in <module>
        from __pypy__ import identity_dict
    ImportError: No module named __pypy__

    ----------------------------------------
Command "python setup.py egg_info" failed with error code -11 in /private/var/folders/t4/n42mh55n05sd6s5hgk1dzdz80000gp/T/pip-build-fSTXPd/pymetabiosis/

【问题讨论】:

  • pypy 仍然与 pandas 冲突。
  • @kilojoules :((但感谢您告诉我)
  • PyDateTime_GET_MONTH(val) = -1; 看起来像 packages.pypy.org/##pandas 上发布的错误。如果就是这样,应该有人解决它。欢迎投稿!
  • @Afflatus 你最终是否通过 pypy 安装了 pandas?
  • @NI6 不记得但我怀疑。

标签: python performance pandas compiler-optimization pypy


【解决方案1】:

pypy v5.9 已开始支持 pandas(和 numpy)

【讨论】:

    【解决方案2】:

    这是我所做的,假设您使用的是 Conda,但 Pip/Venv 也应该可以工作

    创建一个新的 conda 环境

    conda create --name pypy_env
    conda activate pypy_env
    

    使用 conda 安装 pypy3

    conda install pypy3
    

    使用这里的方法Install pip on pypy获取pypy3的Pip

    使用 pypy 安装包

    pypy3 -m pip install pandas
    

    【讨论】:

    • 将它与 pip 一起使用对我不起作用。我检查了 PyPy 的网站,发现:supported packages。似乎不支持 Pandas(至少在没有一些 hacky 解决方法的情况下不支持)
    • 仅供任何发现此答案有用的人参考,请参阅我上面对这个问题的评论 - 但 TL;DR 即使它有效,您也不太可能从这样做中获得太多好处。
    • 不适用于 pypy3 V7.3.7 (python 3.8.12)
    猜你喜欢
    • 2021-07-23
    • 1970-01-01
    • 2011-09-23
    • 1970-01-01
    • 1970-01-01
    • 2016-04-16
    • 1970-01-01
    • 1970-01-01
    • 2019-09-16
    相关资源
    最近更新 更多