brightway-lca / brightway2

Metapackage for brightway2 imports and documentation
https://brightway.dev/
BSD 3-Clause "New" or "Revised" License
100 stars 37 forks source link

Cannot import brightway2 in Jupyter notebook #78

Closed LouiseBru closed 4 months ago

LouiseBru commented 4 months ago

Hello, I'm currently attempting to use Brightway2 for my final project, but I'm encountering issues importing it into Jupyter Notebook. Despite updating Anaconda and everything else possible, I'm still facing errors. Could you assist me? Here's the error message I'm receiving.


TypeError Traceback (most recent call last) Cell In[1], line 1 ----> 1 import brightway2

File ~\anaconda3\envs\brightway_\lib\site-packages\brightway2__init__.py:4 2 from bw2data import 3 from bw2calc import ----> 4 from bw2io import * 6 version = (2, 4, 6)

File ~\anaconda3\envs\brightway_\lib\site-packages\bw2io__init__.py:76 63 from .data import ( 64 add_ecoinvent_33_biosphere_flows, 65 add_ecoinvent_34_biosphere_flows, (...) 73 get_xlsx_example_filepath, 74 ) 75 from .migrations import migrations, Migration, create_core_migrations ---> 76 from .importers import ( 77 CSVImporter, 78 CSVLCIAImporter, 79 Ecospold1LCIAImporter, 80 ExcelImporter, 81 ExcelLCIAImporter, 82 MultiOutputEcospold1Importer, 83 SimaProCSVImporter, 84 SimaProLCIACSVImporter, 85 SingleOutputEcospold1Importer, 86 SingleOutputEcospold2Importer, 87 ) 88 from .units import normalize_units 89 from .unlinked_data import unlinked_data, UnlinkedData

File ~\anaconda3\envs\brightway_\lib\site-packages\bw2io\importers__init__.py:2 1 # -- coding: utf-8 -- ----> 2 from .ecoinvent_lcia import EcoinventLCIAImporter 3 from .ecospold1 import ( 4 MultiOutputEcospold1Importer, 5 NoIntegerCodesEcospold1Importer, 6 SingleOutputEcospold1Importer, 7 ) 8 from .ecospold1_lcia import Ecospold1LCIAImporter

File ~\anaconda3\envs\brightway_\lib\site-packages\bw2io\importers\ecoinvent_lcia.py:19 15 from ..strategies.lcia import fix_ecoinvent_38_lcia_implementation 16 from .base_lcia import LCIAImporter ---> 19 class EcoinventLCIAImporter(LCIAImporter): 20 """ 21 A class for importing ecoinvent-compatible LCIA methods 22 23 """ 25 def init(self, biosphere_database: str | None = None):

File ~\anaconda3\envs\brightway_\lib\site-packages\bw2io\importers\ecoinvent_lcia.py:25, in EcoinventLCIAImporter() 19 class EcoinventLCIAImporter(LCIAImporter): 20 """ 21 A class for importing ecoinvent-compatible LCIA methods 22 23 """ ---> 25 def init(self, biosphere_database: str | None = None): 26 """Initialize an instance of EcoinventLCIAImporter. 27 28 Defines strategies in __init__ because config.biosphere is dynamic. 29 """ 30 self.strategies = [ 31 normalize_units, 32 set_biosphere_type, (...) 38 ), 39 ]

TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

Thank you for your help

BenPortner commented 4 months ago

Hello @LouiseBru,

Which Python version are you using? If you are using 3.9 or lower, could you try updating to Python 10 or higher?

LouiseBru commented 4 months ago

Hello @BenPortner,

I downloaded a newer version of Python and it seems to be working. Thank you very much.

BenPortner commented 4 months ago

You're welcome! Closing this as solved.