brightway

Update brightway without changing project


while working with brightway2 I realized my version was not up to date and tried to update it using conda update brightway2 but it would not do it. I have to set a new project and update brightway2 in this new project to have the latest version running. My question is simple: is there a way to update brightway2 without having to create a new project?


Solution

  • Once you have updated brightway data, running bw.bw2setup() in a new project will give you the most up-to-date methods and biosphere exchanges. You cannot run bw.bw2setup() in a project where bw.bw2setup() has already been run. This is simply because the biosphere3 database already exists.

    Let's suppose you imported brightway2 as bw:

    `import brightway2 as bw
    

    To update your biosphere exchanges, you first need to delete your existing biosphere3 database:

    bw.Database('biosphere3').delete()
    bw.Database('biosphere3').deregister()
    

    If you run bw2setup() now, you will not update your methods, though - brightway will complain about the methods you are trying to save already existing, and quit. I have not found a way to delete the methods using brighway2 methods, but simply deregistering them works:

    all_method_tuples = list(bw.methods)
    for m in all_method_tuples:
        bw.Method(m).deregister()
    

    Now you are ready to import your biosphere exchanges and methods:

    `bw.bw2setup()