Skip to content

Instantly share code, notes, and snippets.

@tngTUDOR
Last active November 24, 2023 12:38
Show Gist options
  • Save tngTUDOR/947f60a5ed965d8d1135b5e4eb5455a3 to your computer and use it in GitHub Desktop.
Save tngTUDOR/947f60a5ed965d8d1135b5e4eb5455a3 to your computer and use it in GitHub Desktop.
install_ecoinvent_in_2_lines
import bw2data as bd
import bw2io as bi
from packaging import version
# We need bw2io version 0.9.dev24 at least
assert version.parse(".".join([str(i) for i in bi.__version__])) >= version.parse("0.9.DEV24")
EI_USERNAME = "my_user"
EI_PASSWORD = "somepassword"
# Let's make the credentials be stored somewhere so that we don't need to provide them every time
# This is only necessary once, and is optional (see below)
# you might need to install ecoinvent_interface package with: `pip install ecoinvent_interface`
from ecoinvent_interface import Settings, permanent_setting
permanent_setting("username", EI_USERNAME)
permanent_setting("password", EI_PASSWORD)
# Secrets files read automatically
my_settings = Settings()
# Now to the magic part: download and install ecoinvent 3.9.1 cutoff
bd.projects.set_current("some new project")
bi.import_ecoinvent_release(
version="3.9.1",
system_model="cutoff",
# Only use the credentials if you didn't add them using the Settings object of ecoinvent_interface above.
#username=EI_USERNAME,
#password=EI_PASSWORD,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment