Importing presamples before brightway2 results in a brightway2 import that does not recognize presamples.
In [1]: import presamples
In [2]: from brightway2 import *
In [3]: lca = LCA({Database('example').random():1}, presamples = ['some_path'])
C:\mypy\anaconda\envs\bw\lib\site-packages\bw2calc\lca.py:90: UserWarning: Skipping presamples; `presamples` not installed
warnings.warn("Skipping presamples; `presamples` not installed")
Importing in the opposite order does not result in this problem.
I think I traced the sequence of events leading to this problem to this, though I don't understand it:
1) When importing presamples, the PackagesDataLoader method is imported.
2) This in turn imports utils.validate_presamples_dirpath
3) The .utils in turn from bw2calc.utils import md5 , hence loading bw2calc
4) bw2calc tries to import the PackagesDataLoader. The import is in a try/except, and since presamples is not yet imported, it excepts. bw2calc is loaded without the PackagesDataLoader.
I'm unsure why the imported bw2calc is modified (and includes the PackagesDataLoader) when presamples is imported second.
A quick fix would be to replace the md5 function with something else (or simply copying it within presamples. It does not seem special enough to cause this headache.
Importing
presamples
beforebrightway2
results in abrightway2
import that does not recognizepresamples
.Importing in the opposite order does not result in this problem.
I think I traced the sequence of events leading to this problem to this, though I don't understand it: 1) When importing presamples, the
PackagesDataLoader
method is imported. 2) This in turn importsutils.validate_presamples_dirpath
3) The.utils
in turnfrom bw2calc.utils import md5
, hence loadingbw2calc
4)bw2calc
tries to import thePackagesDataLoader
. The import is in a try/except, and sincepresamples
is not yet imported, it excepts.bw2calc
is loaded without thePackagesDataLoader
.I'm unsure why the imported
bw2calc
is modified (and includes thePackagesDataLoader
) whenpresamples
is imported second.A quick fix would be to replace the
md5
function with something else (or simply copying it withinpresamples
. It does not seem special enough to cause this headache.