'module 'numpy.distutils.__config__' has no attribute 'blas_opt_info'
I'm trying to study the neural-network-and-deep-learning (http://neuralnetworksanddeeplearning.com/chap1.html). Using the updated version for Python 3 by MichalDanielDobrzanski (https://github.com/MichalDanielDobrzanski/DeepLearningPython). Tried to run it in my command console and it gives an error below. I've tried uninstalling and reinstalling setuptools, theano, and numpy but none have worked thus far. Any help is very appreciated!!
Here's the full error log:
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'
Solution 1:[1]
Additional information:
theano is an obsolete package and shall not be used with modern versions of numpy. However some legacy codebase will be using theano, so the workaround of downgrading numpy < 1.22 will be needed as in the accepted answer. The deprecation has been made in numpy 1.22: see numpy issue #21079.
If one would need to stick with numpy 1.22+, blas_opt_info is located in numpy.distutils.system_info.blas_opt_info, so manually patching theano to use the correct symbol would be another workaround.
Solution 2:[2]
Monkey-patch NumPy.
import numpy as np
try:
np.distutils.__config__.blas_opt_info = np.distutils.__config__.blas_ilp64_opt_info
except Exception:
pass
This working snippet comes directly from 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.
For actively maintained software (...so, not theano is what I'm saying), instead:
- Require NumPy ? 1.22.0.
- Globally replace all broken references to
np.distutils.__config__.blas_opt_infowith working references tonp.distutils.__config__.blas_ilp64_opt_info.
Danger, Will Robinson! Danger!
However, all of the above come with a critical caveat: all of this will break yet again under some future as-yet-undecided NumPy release. Why? To quote 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_infotype output.
</gulp>
Solution 3:[3]
I got a little bad news for you. There is no way to distinguish algorithmically between 01-02-2022 (Feb 1, 2022) and 01-02-2022 (Jan 2, 2022). So technically this source data is the infamous 'garbage in'.
Solution 4:[4]
Somehow I managed to find an alternative option to achieve this using Moment Js Library below is the solution:
function myFunction() {
let formats = ["DD/MM/YYYY", "MM/DD/YYYY", "YYYY/MM/DD", "DD/MM/YYYY hh:mm:ss", "DD/MM/YYYY hh:mm:ss A", "MM/DD/YYYY hh:mm:ss A", "YYYY/MM/DD hh:mm:ss A"]
Logger.log(convertDate("5/1/2022 12:00:00 PM", formats));
}
function convertDate(date, formats){
eval(UrlFetchApp.fetch('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.min.js').getContentText());
let dateMomentObject = moment(date, formats);
let dateObject = dateMomentObject.toDate();
let dateStr = moment(dateObject).format('YYYY-MM-DD');
return dateStr;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jongwook Choi |
| Solution 2 | Cecil Curry |
| Solution 3 | Yuri Khristich |
| Solution 4 | Wolfmania |
