模块 'numpy.distutils.__config__' 没有属性 'blas_opt_info'
module 'numpy.distutils.__config__' has no attribute 'blas_opt_info'
我正在尝试研究神经网络和深度学习 (http://neuralnetworksanddeeplearning.com/chap1.html). Using the updated version for Python 3 by MichalDanielDobrzanski (https://github.com/MichalDanielDobrzanski/DeepLearningPython)。试图在我的命令控制台中 运行 它并在下面给出错误。我已经尝试卸载并重新安装 setuptools、theano 和 numpy,但 none 到目前为止一直有效。非常感谢任何帮助!!
这是完整的错误日志:
WARNING (theano.configdefaults): g++ not available, if using conda: `conda install m2w64-toolchain`
C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\configdefaults.py:560: UserWarning: DeprecationWarning: there is no c++ compiler.This is deprecated and with Theano 0.11 a c++ compiler will be mandatory
warnings.warn("DeprecationWarning: there is no c++ compiler."
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
Traceback (most recent call last):
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\configparser.py", line 168, in fetch_val_for_key
return theano_cfg.get(section, option)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\configparser.py", line 781, in get
d = self._unify_values(section, vars)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\configparser.py", line 1149, in _unify_values
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'blas'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\configparser.py", line 327, in __get__
val_str = fetch_val_for_key(self.fullname,
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\configparser.py", line 172, in fetch_val_for_key
raise KeyError(key)
KeyError: 'blas.ldflags'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ASUS\Documents\GitHub\Neural-network-and-deep-learning-but-for-python-3\test.py", line 156, in <module>
import network3
File "C:\Users\ASUS\Documents\GitHub\Neural-network-and-deep-learning-but-for-python-3\network3.py", line 37, in <module>
import theano
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\__init__.py", line 124, in <module>
from theano.scan_module import (scan, map, reduce, foldl, foldr, clone,
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\scan_module\__init__.py", line 41, in <module>
from theano.scan_module import scan_opt
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\scan_module\scan_opt.py", line 60, in <module>
from theano import tensor, scalar
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\tensor\__init__.py", line 17, in <module>
from theano.tensor import blas
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\tensor\blas.py", line 155, in <module>
from theano.tensor.blas_headers import blas_header_text
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\tensor\blas_headers.py", line 987, in <module>
if not config.blas.ldflags:
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\configparser.py", line 332, in __get__
val_str = self.default()
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\configdefaults.py", line 1284, in default_blas_ldflags
blas_info = np.distutils.__config__.blas_opt_info
AttributeError: module 'numpy.distutils.__config__' has no attribute 'blas_opt_info'
我遇到了同样的问题并解决了将 numpy 降级到版本 1.20.3 的问题:
pip3 install --upgrade numpy==1.20.3
附加信息:
theano
是一个过时的包,不应与现代版本的 numpy 一起使用。但是,某些遗留代码库将使用 theano
,因此需要按照已接受的答案降级 numpy < 1.22 的解决方法。已在 numpy 1.22 中弃用:请参阅 numpy 问题 #21079.
如果需要坚持使用 numpy 1.22+,blas_opt_info
位于 numpy.distutils.system_info.blas_opt_info
,因此手动修补 theano 以使用正确的符号将是另一种解决方法。
Monkey-patch NumPy.
import numpy as np
try:
np.distutils.__config__.blas_opt_info = np.distutils.__config__.blas_ilp64_opt_info
except Exception:
pass
此工作片段直接来自 NumPy maintainer Ralf Gommers (@rgommers), who first defined a similar monkey-patch against the synthetic numpy.__config__
submodule. Issue submitter Alex Rogozhnikov (@arogozhnikov) then improved that by monkey-patching the preferable numpy.distutils.__config__
submodule instead。
对于积极维护的软件(...所以,我说的不是 theano
),而是:
- 需要 NumPy ≥ 1.22.0.
- 全局替换对
np.distutils.__config__.blas_opt_info
的所有损坏引用为对 np.distutils.__config__.blas_opt_info
的有效引用
np.distutils.__config__.blas_ilp64_opt_info
.
危险,威尔·罗宾逊!危险!
但是,以上所有内容都带有一个重要警告:所有这些都将在未来的某个 as-yet-undecided NumPy 版本中再次中断 。 为什么?引用 NumPy maintainer Ralf Gommers (@rgommers) yet again:
This is all going to change when we change build systems, we won't be preserving the system_info
type output.
</gulp>
我正在尝试研究神经网络和深度学习 (http://neuralnetworksanddeeplearning.com/chap1.html). Using the updated version for Python 3 by MichalDanielDobrzanski (https://github.com/MichalDanielDobrzanski/DeepLearningPython)。试图在我的命令控制台中 运行 它并在下面给出错误。我已经尝试卸载并重新安装 setuptools、theano 和 numpy,但 none 到目前为止一直有效。非常感谢任何帮助!!
这是完整的错误日志:
WARNING (theano.configdefaults): g++ not available, if using conda: `conda install m2w64-toolchain`
C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\configdefaults.py:560: UserWarning: DeprecationWarning: there is no c++ compiler.This is deprecated and with Theano 0.11 a c++ compiler will be mandatory
warnings.warn("DeprecationWarning: there is no c++ compiler."
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
Traceback (most recent call last):
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\configparser.py", line 168, in fetch_val_for_key
return theano_cfg.get(section, option)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\configparser.py", line 781, in get
d = self._unify_values(section, vars)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\configparser.py", line 1149, in _unify_values
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'blas'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\configparser.py", line 327, in __get__
val_str = fetch_val_for_key(self.fullname,
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\configparser.py", line 172, in fetch_val_for_key
raise KeyError(key)
KeyError: 'blas.ldflags'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ASUS\Documents\GitHub\Neural-network-and-deep-learning-but-for-python-3\test.py", line 156, in <module>
import network3
File "C:\Users\ASUS\Documents\GitHub\Neural-network-and-deep-learning-but-for-python-3\network3.py", line 37, in <module>
import theano
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\__init__.py", line 124, in <module>
from theano.scan_module import (scan, map, reduce, foldl, foldr, clone,
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\scan_module\__init__.py", line 41, in <module>
from theano.scan_module import scan_opt
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\scan_module\scan_opt.py", line 60, in <module>
from theano import tensor, scalar
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\tensor\__init__.py", line 17, in <module>
from theano.tensor import blas
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\tensor\blas.py", line 155, in <module>
from theano.tensor.blas_headers import blas_header_text
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\tensor\blas_headers.py", line 987, in <module>
if not config.blas.ldflags:
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\configparser.py", line 332, in __get__
val_str = self.default()
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python39\lib\site-packages\theano\configdefaults.py", line 1284, in default_blas_ldflags
blas_info = np.distutils.__config__.blas_opt_info
AttributeError: module 'numpy.distutils.__config__' has no attribute 'blas_opt_info'
我遇到了同样的问题并解决了将 numpy 降级到版本 1.20.3 的问题:
pip3 install --upgrade numpy==1.20.3
附加信息:
theano
是一个过时的包,不应与现代版本的 numpy 一起使用。但是,某些遗留代码库将使用 theano
,因此需要按照已接受的答案降级 numpy < 1.22 的解决方法。已在 numpy 1.22 中弃用:请参阅 numpy 问题 #21079.
如果需要坚持使用 numpy 1.22+,blas_opt_info
位于 numpy.distutils.system_info.blas_opt_info
,因此手动修补 theano 以使用正确的符号将是另一种解决方法。
Monkey-patch NumPy.
import numpy as np
try:
np.distutils.__config__.blas_opt_info = np.distutils.__config__.blas_ilp64_opt_info
except Exception:
pass
此工作片段直接来自 NumPy maintainer Ralf Gommers (@rgommers), who first defined a similar monkey-patch against the synthetic numpy.__config__
submodule. Issue submitter Alex Rogozhnikov (@arogozhnikov) then improved that by monkey-patching the preferable numpy.distutils.__config__
submodule instead。
对于积极维护的软件(...所以,我说的不是 theano
),而是:
- 需要 NumPy ≥ 1.22.0.
- 全局替换对
np.distutils.__config__.blas_opt_info
的所有损坏引用为对np.distutils.__config__.blas_opt_info
的有效引用np.distutils.__config__.blas_ilp64_opt_info
.
危险,威尔·罗宾逊!危险!
但是,以上所有内容都带有一个重要警告:所有这些都将在未来的某个 as-yet-undecided NumPy 版本中再次中断 。 为什么?引用 NumPy maintainer Ralf Gommers (@rgommers) yet again:
This is all going to change when we change build systems, we won't be preserving the
system_info
type output.
</gulp>