我读了很多关于这个错误的帖子,我发布这个的原因是因为我在试图安装statmodels包时得到了错误,而不是我的一个程序。
如何纠正安装包时的错误?
$ 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
读到建议的回答,我跑了:
sudo pip3 install numpy --upgrade
Requirement already up-to-date: numpy in /usr/local/lib/python3.2/dist-packages
Cleaning up...
卸载了matplotlib和numpy,然后再次安装时,我得到以下消息:
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,重新安装返回以下内容:
sudo pip3 install numpy
Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/lib/python3/dist-packages
Cleaning up..
.
这是Python 3.*中numpy遇到的一个错误。它似乎已经在源代码中修复了,但我不知道它是否发现自己已经发布了。
请先升级numpy再安装statsmodel。
在Python 2中。, .keys()函数将返回一个列表,但在3。返回一个迭代器,这就是bug的原因。