when I try to import brightway2 into jupyter-lab I get attribute error and I have tried several ways but the problem continues. So I need help.
to open jupyter-lab I follow this steps - from the anaconda -> environment -> brightway -> open with terminal.
then, I open the jupyter-lab with the terminal.
then, I am trying to import brightway to the jupyter-lab by the command from brightway2 import *
gives me the following attribute error below. Also when I try to do this directly through the terminal from anaconda I get the same error. I also tried different versions of numpy but didn't work. My brightway and everything else is updated.
**My computer: ** MacBook Pro 2017 - 2.3 GHz Dual-Core Intel Core i5 , Intel Iris Plus Graphics 640 1536 MB , 16 GB 2133 MHz LPDDR3 , macOS 13.6.1 (22G313)
has anyone else had this problem, how did you solve it, is there a method you recommend? how can I solve this?
The error:
AttributeError Traceback (most recent call last)
Cell In[1], line 1
----> 1 from brightway2 import *
File ~/anaconda3/envs/bw/lib/python3.11/site-packages/brightway2/__init__.py:2
1 # -*- coding: utf-8 -*
----> 2 from bw2data import *
3 from bw2calc import *
4 from bw2io import *
File ~/anaconda3/envs/bw/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 ~/anaconda3/envs/bw/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 ~/anaconda3/envs/bw/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 ~/anaconda3/envs/bw/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 ~/anaconda3/envs/bw/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 ~/anaconda3/envs/bw/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 ~/anaconda3/envs/bw/lib/python3.11/site-packages/numpy/__init__.py:324, in __getattr__(attr)
319 warnings.warn(
320 f"In the future `np.{attr}` will be defined as the "
321 "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
323 if attr in __former_attrs__:
--> 324 raise AttributeError(__former_attrs__[attr])
326 if attr == 'testing':
327 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
- Also when I try to do this from anaconda directly through the terminal I get the same error.
- I tried to update everything dumpy, brightway.
- I also created another environment on anaconda for brightway and opened the jupyter-lab again and got the same error for
from brightway2 import *
command. - I tried different versions of numpy like 1.19.0 and 1.20.0 but didn't work.
This was fixed in commit 0509092 and released in 3.6.6 on Februray 24, 2023.
On conda you can upgrade using: