提问人:Büşra Haliloğlu 提问时间:11/7/2023 更新时间:11/8/2023 访问量:28
“from brightway2 import *”的属性错误
Attribute Error for "from brightway2 import *"
问:
当我尝试将 brightway2 导入 jupyter-lab 时,我收到属性错误,我尝试了几种方法,但问题仍然存在。所以我需要帮助。
要打开jupyter-lab,我按照以下步骤操作 - 从anaconda ->环境->brightway ->使用终端打开。
然后,我打开带有终端的 jupyter-lab。
然后,我试图通过命令将 brightway 导入 jupyter-lab,在下面出现以下属性错误。此外,当我尝试直接通过 anaconda 的终端执行此操作时,我遇到了同样的错误。我也尝试了不同版本的numpy,但没有用。我的 brightway 和其他一切都更新了。
**我的电脑: ** MacBook Pro 2017 - 2.3 GHz 双核 Intel Core i5 , Intel Iris Plus Graphics 640 1536 MB , 16 GB 2133 MHz LPDDR3 , macOS 13.6.1 (22G313)
有没有人遇到过这个问题,你是怎么解决的,有没有你推荐的方法?我该如何解决这个问题?from brightway2 import *
错误:
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
- 此外,当我尝试直接通过终端从 anaconda 执行此操作时,我遇到了同样的错误。
- 我试图更新所有东西,明亮的方式。
- 我还在 anaconda 上为 brightway 创建了另一个环境,并再次打开 jupyter-lab,并得到了相同的命令错误。
from brightway2 import *
- 我尝试了不同版本的numpy,如1.19.0和1.20.0,但没有用。
答:
0赞
Chris Mutel
11/8/2023
#1
此问题已在提交0509092中修复,并于 2023 年 2 月 24 日在 3.6.6 中发布。
在 conda 上,您可以使用以下命令进行升级:
conda update bw2data"=3.6.6"
上一个:卷积神经网络无属性错误
下一个:Python 链表打印问题
评论
.ipynb