Temporalis library in brightway2.5 AttributeError: 'NoneType' object has no attribute 'get'

92 Views Asked by At

I downloaded temporalis library to brightway from terminal. During installation it gave a warning that not all packages could be installed. The error is as follows:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed.(https://i.stack.imgur.com/wtVhl.png)his behavior is the source of the following dependency conflicts.
brightway2 2.4.2 requires bw2calc==1.8.1, but you have bw2calc 2.0.dev16 which is incompatible.
brightway2 2.4.2 requires bw2data<3.99, but you have bw2data 4.0.dev33 which is incompatible.

and here the screenshots from the jupyter-lab for the error code

code 1

code 2

but since Temporalis works, I tried to get a result for my project using the codes in the following link

"https://github.com/brightway-lca/from-the-ground-up/blob/main/temporal/1%20-%20Introduction.ipynb"

on github, but then the first error I got said that brightway2.5 is compatible with Temporalis, so I installed an environment with the new brightway2.5 on anaconda and tried again. Then jupyter-lab suggested me to migrate projects in another error, I applied it as well, but I still get an error like this in the line 10. do you know why and how to solve this? any help would be appreciated.

**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).

[1] from bw_temporalis import easy_timedelta_distribution, easy_datetime_distribution, TemporalisLCA, Timeline, TemporalDistribution
from bw_temporalis.lcia import characterize_methane, characterize_co2
from bw2data import *
import bw2data as bd
import bw2io as bi
import bw2calc as bc
import bw_temporalis as bwt
import bw_graph_tools as graph
import numpy as np
import pandas as pd

[2] projects.set_current('bw2.5')

[3] projects.migrate_project_25

[4] bd.Database('thesis  0.1')

[5] ei = bd.Database("thesis  0.1")

[6] activity_name = 'copy_Köck building'

[7] my_activity = [x for x in ei if x['name'] == activity_name][0]

[8] my_activity['temporal distribution'] = bwt.easy_timedelta_distribution(
      start=0,
      end=10,
      resolution="Y",
      steps=11,
    )

[9] temporal_distribution: easy_timedelta_distribution(
                    start=0,
                    end=100, # Range includes both start and end
                    resolution="Y",  # M for months, Y for years, etc.
                    steps=10)

[10] lca = bc.LCA({my_activity: 1}, ("EF  v3.0", "climate change", "global warming potential (GWP100)"))
lca.lci()
lca.lcia()

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[11], line 1
----> 1 lca = bc.LCA({my_activity: 1}, ("EF  v3.0", "climate change", "global warming potential (GWP100)"))
      2 lca.lci()
      3 lca.lcia()

File ~/anaconda3/envs/bw25.1/lib/python3.11/site-packages/bw2calc/lca.py:97, in LCA.__init__(self, demand, method, weighting, normalization, data_objs, remapping_dicts, log_config, seed_override, use_arrays, use_distributions, selective_use)
     95 if data_objs is None:
     96     self.ensure_bw2data_available()
---> 97     demand, self.packages, remapping_dicts = prepare_lca_inputs(
     98         demand=demand,
     99         method=method,
    100         weighting=weighting,
    101         normalization=normalization,
    102     )
    103     self.method = method
    104     self.weighting = weighting

File ~/anaconda3/envs/bw25.1/lib/python3.11/site-packages/bw2data/compat.py:69, in prepare_lca_inputs(demand, method, weighting, normalization, demands, remapping, demand_database_last)
     59 def prepare_lca_inputs(
     60     demand=None,
     61     method=None,
   (...)
     66     demand_database_last=True,
     67 ):
     68     """Prepare LCA input arguments in Brightway 2.5 style."""
---> 69     if not projects.dataset.data.get("25"):
     70         raise Brightway2Project(
     71             "Please use `projects.migrate_project_25` before calculating using Brightway 2.5"
     72         )
     74     databases.clean()

AttributeError: 'NoneType' object has no attribute 'get'

[11] lca.score

[12] tlca = TemporalisLCA(lca)

projects.migrate.project_25() error

code with the adjustments 1

code with the adjustments 2

1

There are 1 best solutions below

1
On

You need to run the function :)

Not:

[3] projects.migrate_project_25

But:

[3] projects.migrate_project_25()

If this doesn't work, the best alternative is to create a new project and re-import your data. I think you could also try to make sure that projects.dataset.data has the correct form:

projects.dataset.data = {}
projects.dataset.save()

And then try to run projects.migrate_project_25()

And since you are in 2.5, don't do this:

[6] activity_name = 'copy_Köck building'

[7] my_activity = [x for x in ei if x['name'] == activity_name][0]

But instead:

my_activity = bd.get_node(database="thesis  0.1", name='copy_Köck building')