【问题标题】:python 3 + statsmodels?python 3 + statsmodels?
【发布时间】:2014-06-14 03:22:56
【问题描述】:

如果我这样做 sudo pip3 install statsmodels 我会出错。我在下面粘贴了控制台输出的末尾。我看到一个 numpy 1.7 警告,但如果我这样做 pip3 freeze | grep numpy,我发现我正在使用 numpy==1.8.1

这是输出。有什么想法吗?

/usr/lib/python3/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]

 #warning "Using deprecated NumPy API, disable it by " \

  ^

statsmodels/tsa/kalmanf/kalman_loglike.c: In function ‘__Pyx_TraceSetupAndCall’:

statsmodels/tsa/kalmanf/kalman_loglike.c:7021:17: error: ‘PyFrameObject’ has no member named ‘f_tstate’

         (*frame)->f_tstate = PyThreadState_GET();

                 ^

In file included from /usr/lib/python3/dist-packages/numpy/core/include/numpy/ndarrayobject.h:26:0,

                 from /usr/lib/python3/dist-packages/numpy/core/include/numpy/arrayobject.h:4,

                 from statsmodels/tsa/kalmanf/kalman_loglike.c:257:

statsmodels/tsa/kalmanf/kalman_loglike.c: At top level:

/usr/lib/python3/dist-packages/numpy/core/include/numpy/__multiarray_api.h:1629:1: warning: ‘_import_array’ defined but not used [-Wunused-function]

 _import_array(void)

 ^

In file included from /usr/lib/python3/dist-packages/numpy/core/include/numpy/ufuncobject.h:327:0,

                 from statsmodels/tsa/kalmanf/kalman_loglike.c:258:

/usr/lib/python3/dist-packages/numpy/core/include/numpy/__ufunc_api.h:241:1: warning: ‘_import_umath’ defined but not used [-Wunused-function]

 _import_umath(void)

 ^

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/statsmodels/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ukof84o0-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/statsmodels
Storing debug log for failure in /home/kurt/.pip/pip.log

【问题讨论】:

  • 我的意思是,从该输出来看,他们的 C 代码扩展中似乎存在错误。
  • 哪个python 3? python 3.4 需要最新的 cython 版本,你需要重建 statsmodels 中的所有 cython 扩展。 python 3.2 和 3.3 应该可以正常工作,并且已经可以正常工作很长时间了。下一个 statsmodels 版本将支持 python 3.4。
  • 这就是我解决问题的方法。我在 python 3.4 附带的 Ubuntu 14.04 上。我做了find -name '*.pyx' 来查找每个 Cython 文件并在每个文件上运行 cython3 -a(只有 3 个文件)。

标签: python-3.x statsmodels


【解决方案1】:

据我所知,statsmodels 0.5.0 根本不适用于 Python 3.4,即使安装了 Cython 0.20.1(最新)。但是,最新的 master 安装得很好,所以如果您愿意使用未发布的版本,这里有一种方法:

git clone https://github.com/statsmodels/statsmodels
cd statsmodels
pip install .

更新:使用最新版本应该没有必要 - 请参阅下面 Rasmus Larsen 的评论。

【讨论】:

  • 你也可以试试pip3 install git+git://github.com/statsmodels/statsmodels,它的好处是你不需要克隆存储库。然后要升级到最新版本,您可以输入:pip3 install --upgrade git+git://github.com/statsmodels/statsmodels
  • 对于未来的读者,请使用支持 python 3.4 的 statsmodels 0.6.0:statsmodels.sourceforge.net/binaries
  • 感谢pip install . 对我有用,而python setup.py buildpython setup.py install 的安装部分没有。
猜你喜欢
  • 2013-05-25
  • 1970-01-01
  • 2016-02-13
  • 2016-01-08
  • 1970-01-01
  • 2016-12-12
  • 2018-07-25
  • 2021-03-01
  • 2015-01-15
相关资源
最近更新 更多