Unfortunately I'm getting an error when importing bw2data (or any other bw2 package). It says that the package 'numpy' has no attribute 'bool'. I already tried deleting and reinstalling the whole bw2 conda environment as well as update bw2 and update numpy. Somehow nothing seems to work.
The issue was raised when I wanted to start analysing a supply chain via Graph Traversal. I installed bw_graph_tools and from there on I always got the error raise.
Any help is very much appreciated.
Many thanks in advance.
ERROR MESSAGE:
/Users/Dominik/opt/anaconda3/envs/bw2/lib/python3.11/site-packages/bw2data/data_store.py:172: FutureWarning: In the future np.bool will be defined as the corresponding NumPy scalar.
(numpy_string('negative'), np.bool),
AttributeError Traceback (most recent call last)
Cell In[5], line 1
----> 1 import bw2data as bd
File ~/opt/anaconda3/envs/bw2/lib/python3.11/site-packages/bw2data/init.py:64
61 config.p = preferences
63 from .serialization import JsonWrapper
---> 64 from .database import DatabaseChooser as Database, get_activity
65 from .data_store import DataStore, ProcessedDataStore
66 from .method import Method
File ~/opt/anaconda3/envs/bw2/lib/python3.11/site-packages/bw2data/database.py:6
3 from eight import *
5 from . import databases, config
----> 6 from .backends.single_file import SingleFileDatabase
7 from .backends.json import JSONDatabase
8 from .backends.peewee import SQLiteBackend
File ~/opt/anaconda3/envs/bw2/lib/python3.11/site-packages/bw2data/backends/init.py:5
2 from future import print_function, unicode_literals
3 from eight import *
----> 5 from .base import LCIBackend
6 from .peewee import SQLiteBackend
7 from .json import JSONDatabase
File ~/opt/anaconda3/envs/bw2/lib/python3.11/site-packages/bw2data/backends/base.py:12
3 from eight import *
5 from .. import (
6 config,
7 databases,
(...)
10 projects,
11 )
---> 12 from ..data_store import ProcessedDataStore
13 from ..errors import UntypedExchange, InvalidExchange, UnknownObject
14 from ..query import Query
File ~/opt/anaconda3/envs/bw2/lib/python3.11/site-packages/bw2data/data_store.py:151
147 self.validator(data)
148 return True
--> 151 class ProcessedDataStore(DataStore):
152 """
153 Brightway2 data stores that can be processed to NumPy arrays. In addition to metadata and (optionally) validator, subclasses should define:
154
(...)
160
161 """
162 dtype_fields = None
File ~/opt/anaconda3/envs/bw2/lib/python3.11/site-packages/bw2data/data_store.py:172, in ProcessedDataStore()
162 dtype_fields = None
163 # Numpy columns names can't be unicode
164 base_uncertainty_fields = [
165 (numpy_string('uncertainty_type'), np.uint8),
166 (numpy_string('amount'), np.float32),
167 (numpy_string('loc'), np.float32),
168 (numpy_string('scale'), np.float32),
169 (numpy_string('shape'), np.float32),
170 (numpy_string('minimum'), np.float32),
171 (numpy_string('maximum'), np.float32),
--> 172 (numpy_string('negative'), np.bool),
173 ]
175 @property
176 def dtype(self):
177 """Returns both the generic base_uncertainty_fields plus class-specific dtype_fields. dtype determines the columns of the :ref:processed array <processing-data>."""
File ~/opt/anaconda3/envs/bw2/lib/python3.11/site-packages/numpy/init.py:313, in getattr(attr)
308 warnings.warn(
309 f"In the future np.{attr} will be defined as the "
310 "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
312 if attr in former_attrs:
--> 313 raise AttributeError(former_attrs[attr])
315 if attr == 'testing':
316 import numpy.testing as testing
AttributeError: module 'numpy' has no attribute 'bool'.
np.bool was a deprecated alias for the builtin bool. To avoid this error in existing code, use bool by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.bool_ here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
Dear brightway community.
Unfortunately I'm getting an error when importing bw2data (or any other bw2 package). It says that the package 'numpy' has no attribute 'bool'. I already tried deleting and reinstalling the whole bw2 conda environment as well as update bw2 and update numpy. Somehow nothing seems to work.
The issue was raised when I wanted to start analysing a supply chain via Graph Traversal. I installed bw_graph_tools and from there on I always got the error raise.
Any help is very much appreciated. Many thanks in advance.
ERROR MESSAGE:
/Users/Dominik/opt/anaconda3/envs/bw2/lib/python3.11/site-packages/bw2data/data_store.py:172: FutureWarning: In the future
np.bool
will be defined as the corresponding NumPy scalar. (numpy_string('negative'), np.bool),AttributeError Traceback (most recent call last) Cell In[5], line 1 ----> 1 import bw2data as bd
File ~/opt/anaconda3/envs/bw2/lib/python3.11/site-packages/bw2data/init.py:64 61 config.p = preferences 63 from .serialization import JsonWrapper ---> 64 from .database import DatabaseChooser as Database, get_activity 65 from .data_store import DataStore, ProcessedDataStore 66 from .method import Method
File ~/opt/anaconda3/envs/bw2/lib/python3.11/site-packages/bw2data/database.py:6 3 from eight import * 5 from . import databases, config ----> 6 from .backends.single_file import SingleFileDatabase 7 from .backends.json import JSONDatabase 8 from .backends.peewee import SQLiteBackend
File ~/opt/anaconda3/envs/bw2/lib/python3.11/site-packages/bw2data/backends/init.py:5 2 from future import print_function, unicode_literals 3 from eight import * ----> 5 from .base import LCIBackend 6 from .peewee import SQLiteBackend 7 from .json import JSONDatabase
File ~/opt/anaconda3/envs/bw2/lib/python3.11/site-packages/bw2data/backends/base.py:12 3 from eight import * 5 from .. import ( 6 config, 7 databases, (...) 10 projects, 11 ) ---> 12 from ..data_store import ProcessedDataStore 13 from ..errors import UntypedExchange, InvalidExchange, UnknownObject 14 from ..query import Query
File ~/opt/anaconda3/envs/bw2/lib/python3.11/site-packages/bw2data/data_store.py:151 147 self.validator(data) 148 return True --> 151 class ProcessedDataStore(DataStore): 152 """ 153 Brightway2 data stores that can be processed to NumPy arrays. In addition to
metadata
and (optionally)validator
, subclasses should define: 154 (...) 160 161 """ 162 dtype_fields = NoneFile ~/opt/anaconda3/envs/bw2/lib/python3.11/site-packages/bw2data/data_store.py:172, in ProcessedDataStore() 162 dtype_fields = None 163 # Numpy columns names can't be unicode 164 base_uncertainty_fields = [ 165 (numpy_string('uncertainty_type'), np.uint8), 166 (numpy_string('amount'), np.float32), 167 (numpy_string('loc'), np.float32), 168 (numpy_string('scale'), np.float32), 169 (numpy_string('shape'), np.float32), 170 (numpy_string('minimum'), np.float32), 171 (numpy_string('maximum'), np.float32), --> 172 (numpy_string('negative'), np.bool), 173 ] 175 @property 176 def dtype(self): 177 """Returns both the generic
base_uncertainty_fields
plus class-specificdtype_fields
.dtype
determines the columns of the :ref:processed array <processing-data>
."""File ~/opt/anaconda3/envs/bw2/lib/python3.11/site-packages/numpy/init.py:313, in getattr(attr) 308 warnings.warn( 309 f"In the future
np.{attr}
will be defined as the " 310 "corresponding NumPy scalar.", FutureWarning, stacklevel=2) 312 if attr in former_attrs: --> 313 raise AttributeError(former_attrs[attr]) 315 if attr == 'testing': 316 import numpy.testing as testingAttributeError: module 'numpy' has no attribute 'bool'.
np.bool
was a deprecated alias for the builtinbool
. To avoid this error in existing code, usebool
by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, usenp.bool_
here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations