安装 statsmodels 时,出现以下错误:RuntimeError: 字典在迭代过程中改变了大小 [英] when installing statsmodels, I get the following error:RuntimeError: dictionary changed size during iteration

查看:35
本文介绍了安装 statsmodels 时,出现以下错误:RuntimeError: 字典在迭代过程中改变了大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了很多关于这个错误的帖子,我发布这个的原因是因为我在尝试安装 statsmodels 包时遇到了这个错误,而不是我的程序之一.

I have read a lot of posts about this error, and the reason I am posting this is because I get the error when trying to install statsmodels package, and not one of my programs.

如何在安装软件包时更正错误?

how do I correct the error when installing a package?

$ sudo pip3 install statsmodels
Downloading/unpacking statsmodels
  Downloading statsmodels-0.5.0.tar.gz (5.5MB): 5.5MB downloaded
  Running setup.py (path:/tmp/pip_build_root/statsmodels/setup.py) egg_info for package statsmodels
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_root/statsmodels/setup.py", line 463, in <module>
        check_dependency_versions(min_versions)
      File "/tmp/pip_build_root/statsmodels/setup.py", line 109, in check_dependency_versions
        from scipy.version import short_version as spversion
      File "/usr/lib/python3/dist-packages/scipy/__init__.py", line 124, in <module>
        pkgload(verbose=SCIPY_IMPORT_VERBOSE,postpone=True)
      File "/usr/local/lib/python3.2/dist-packages/numpy/_import_tools.py", line 177, in __call__
        for package_name in self._get_sorted_names():
      File "/usr/local/lib/python3.2/dist-packages/numpy/_import_tools.py", line 114, in _get_sorted_names
        for name in depend_dict.keys():
    RuntimeError: dictionary changed size during iteration
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_root/statsmodels/setup.py", line 463, in <module>

    check_dependency_versions(min_versions)

  File "/tmp/pip_build_root/statsmodels/setup.py", line 109, in check_dependency_versions

    from scipy.version import short_version as spversion

  File "/usr/lib/python3/dist-packages/scipy/__init__.py", line 124, in <module>

    pkgload(verbose=SCIPY_IMPORT_VERBOSE,postpone=True)

  File "/usr/local/lib/python3.2/dist-packages/numpy/_import_tools.py", line 177, in __call__

    for package_name in self._get_sorted_names():

  File "/usr/local/lib/python3.2/dist-packages/numpy/_import_tools.py", line 114, in _get_sorted_names

    for name in depend_dict.keys():

RuntimeError: dictionary changed size during iteration

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/statsmodels

阅读建议的回复,我跑了:

Reading the suggested response, I ran:

sudo pip3 install numpy --upgrade
Requirement already up-to-date: numpy in /usr/local/lib/python3.2/dist-packages
Cleaning up...

卸载 matplotlib 和 numpy,然后再次安装时,我收到以下消息:

Uninstalled matplotlib and numpy and then upon installing it again, I get the following message:

sudo pip3 install matplotlib
Requirement already satisfied (use --upgrade to upgrade): matplotlib in /usr/local/lib/python3.2/dist-packages
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.5 in /usr/lib/python3/dist-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /usr/local/lib/python3.2/dist-packages/python_dateutil-2.2-py3.2.egg (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): tornado in /usr/local/lib/python3.2/dist-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): pyparsing>=1.5.6 in /usr/local/lib/python3.2/dist-packages/pyparsing-2.0.2-py3.2.egg (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): nose in /usr/local/lib/python3.2/dist-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): six in /usr/local/lib/python3.2/dist-packages/six-1.7.2-py3.2.egg (from python-dateutil->matplotlib)
Cleaning up...

对于 numpy,重新安装会返回以下内容:

For numpy, the reinstall returns the following:

sudo pip3 install numpy
Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/lib/python3/dist-packages
Cleaning up..

.

推荐答案

这是一个在 Python 3.* 中遇到 numpy 的错误.它似乎已在源代码中修复,但我不知道它是否已发布.

It's a bug hitting numpy in Python 3.*. It seems to have been fixed in the source, but I don't know if it has found itself to a release yet.

在安装 statsmodel 之前尝试升级 numpy.

Try upgrading numpy before installing statsmodel.

在 Python 2. 中,.keys() 函数将返回一个列表,但在 3. 中它返回一个迭代器,因此是错误的原因.

In Python 2., the .keys() function would return a list, but in 3. it returns an iterator, hence the reason to the bug.

这篇关于安装 statsmodels 时,出现以下错误:RuntimeError: 字典在迭代过程中改变了大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆