Import of Ecoinvent 2.2 and Ecoinvent 3.x fail with Brightway - brightway

The import of Ecoinvent 2.2 and 3.x does not happen. I do not understand what is the issue here.
I have downloaded both 2 and 3 versions from Ecoinvent.org but both the Ecospold1 and 2 importers show me the same (or the lack of) results.
`from brightway2 import *
ei33cutoff = SingleOutputEcospold2Importer(
r"C:\Users\HS254581\Documents\test\ecoinvent33cutoff\datasets",
"ecoinvent 3.3 cutoff"
)
ei33cutoff.apply_strategies()
ei33cutoff.statistics()`
All I get is
"Extracting XML data from 13831 datasets"
WITHOUT any error message. I have kept it running for hours sometimes, ultimately I have to quit.
I can however import Forwast database, do some LCA calculations here and some CSV files from Simapro.
I read most of the questions answered here and on github, but cannot find a solution to this problem.
Send help!
P.S. I am using Python 3.7 with Spyder. Here I need to activate bw2 environment in Anaconda prompt and set Python interpreter path to default. Have installed kernels too. This is the only way it seems to work. Also updated conda and brightway packages today just in case.

Related

python-docx import is not able to be imported even though the library is installed

System:
MacBook Pro (13-inch, 2020, Two Thunderbolt 3 ports)
Processor 1.4 GHz Quad-Core Intel Core i5
Memory 16GB
OS macOs Monterey version 12.6.1
I'm still fairly new to Python and just learned about the docx library.
I get the following error in Visual Studio Code about the docx library.
Import "docx" could not be resolved.
enter image description here
When I check to see the version installed I get the following:
pip3 show python-docx
Name: python-docx
Version: 0.8.11
I am able to create Word documents with one Python script even with the import issue. However, I've tried to create one using a table and this is what is causing me issues. I'm not sure if the import issue is the root cause.
When I run my script I get the following:
python3 test.py
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/docx/styles/styles.py:139: UserWarning: style lookup by style_id is deprecated. Use style name as key instead.
return self._get_style_id_from_style(self[style_name], style_type)`
The code causing the error:
Add review question table
table = document.add_table(rows=1, cols=3)
table.style = 'TableGrid'
In researching I found I may need to import the following:
from docx.oxml.table import CT_TableStyle
And add the following to that section:
# Add review question table
table = document.add_table(rows=1, cols=3)
style = CT_TableStyle()
style.name = 'TableGrid'
table.style = style
I now get the following warning:
Import "docx.oxml.table" could not be resolved
And the following error when running the script:
line 2, in
from docx.oxml.table import CT_TableStyle
ImportError: cannot import name 'CT_TableStyle' from 'docx.oxml.table' (/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/docx/oxml/table.py)
I also created a virtual environment and still have the same issues. If you need additional details, just let me know what to provide.
Kind regards,
Marcus

How to silence warning from import IPython.nbformat: "UserWarning: nbformat.current is deprecated."

I'm working with the example code for importing an IPython (Jupyter) notebook,
Importing Notebooks. The example code still runs fine, however it generates a warning that I would like to understand and fix:
site-packages/nbformat/current.py:15: UserWarning: nbformat.current is deprecated.
- use nbformat for read/write/validate public API
- use nbformat.vX directly to composing notebooks of a particular version
warnings.warn("""nbformat.current is deprecated.
This warning has been discussed since 2015, at least, and yet I cannot find any constructive advice about what to do about it. Is this a warning that can be addressed by fixing code, or is it a function that will disappear from IPython without a replacement?
If you follow the link to the IPython blog, they claim that there is a newer version, but their link points to a non-existent page.
This code example is widely discussed in other threads in Stack Overflow, for example
python access functions in ipython notebook
Keep in mind the example you've linked up is for a much older version of Jupyter - 4.x. The page with these examples has been relocated at some point, and for the 5.7.6 version of Jupyter (the most recent as of writing this) it's located here.
First, replace the from IPython.nbformat import current import with ​from nbformat import read
Then, replace this part of the 4.x snippet:
with io.open(path, 'r', encoding='utf-8') as f:
nb = current.read(f, 'json')
with the newer version:
with io.open(path, 'r', encoding='utf-8') as f:
nb = read(f, 4)

Python 3.5 How do I list classes/functions available in an import package?

I'm porting all my Python code from 2.7 to 3.5 and keep running into issues where my imported packages don't contain the same classes/functions as they did in 2.7. I DO NOT want to use one of the methods where you can support both 2.7 and 3x. I'm dropping 2.7 entirely.
Is there a way to search an imported package for a specific thing or to list the classes/functions in a nested display?
Right now, I'm trying to find the escape_string() function in mysql-connector-python (v8x) but I keep needing something to explore packages. The docs for the mysql-connector-python package say that it's in mysql.connector.MySQL but there's no such attribute.
Thanks...
If you believe the documentation is wrong, I would open an issue with them and also double and triple check that you have installed the correct package.
To list the classes/functions of a module you can use:
import os # or whatever
print(list(os.__dict__.keys()))

Rodeo giving error on Excel import working in Spyder

Full disclosure: I am a total beginner when it comes to Python in particular and programming in general. So please bear with me.
Today I tried for the first time to play around some datasets on my own, outside of the sandboxed environment of online courses.
I downloaded both Anaconda and Rodeo (which somehow I feel more akin to than, say, Spyder or Jupyter).
Wrote down this code. It works in Spyder.
import numpy as np
import pandas as pd
myexcel="C:/Users/myname/folder/subfolder/file.xlsx"
xl=pd.ExcelFile(myexcel)
mydf=xl.parse(0)
print(mydf.head())
However, if I try to run the same code in Rodeo I get the following error message. Here, I am showing just a part.
----> 4 xl=pd.ExcelFile(myexcel)
ImportError: No module named 'xlrd'
I am getting that in Rodeo the script fail because it is missing the xlrd package, which admittedly after checking with help("modules") is not there. But I don't fully get the problem: if xlrd was quintessential to the correct execution of this code, then why doesn't it fail in Spyder?

mkl_blas_dgemm_alloc not found in mkl_intel_thread

I developed a a tool in python 3.5 some time ago which currently only uses differential evolution from scipy to do its task. For some reasons I had to change settings on my machine and switch to use python in a virtual environment.
My specs now:
win 10 64 bit
used pip 9.0.1
numpy 1.12.1+mkl
scipy 0.19.0
python 3.6.1
I have a different env using python 2.7 flying around somewhere else.
Now my problem....everytime the differential evolution function gets its first set of data it crashes after returning the differential_evolution step value.
The differential_evolution call can be found under ./libraries/methods/differential_evoluation.py line 76
The pop-up Error is "Entry point 'mkl_blas_dgemm_alloc wasn't found in 'mkl_intel_thread.dll'." And the printed error is "Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll." Please notice that my system language is german therfore the pop-up message was translated by me.
I don't know whether this is relevant but my directory structure is:
>some_place/location1/goal.py
>some_place/location2/env/
I didn't work with virtualenv before and in addition to this i used python 3.5. I'd appreciate any help or instructions on how to add more information to this case to help clarify my problem.
Yours sincerely
OK I'm back with more information. Maybe someone else will stumble uppon it. To be clear: I do not know the fix or reason. I just tried a bunch of stuff.
Using
python 3.5.3,numpy 1.11.1+mkl and scipy-0.18.0 or scipy-0.19.0
made the error disappear. I couldn't try numpy 1.11.1 or 1.11.2 for python 3.6 because this kind soul sadly doesn't offer those versions anymore. I found the 1.11.1 version for python 3.5 somewhere on my disk.
From my testing i can tell that it breaks once i use numpy 1.11.3 or higher. 1.11.1 works fine. Therefore I assume that some changes happened either in numpy between 1.11.1 and 1.11.3 which break it OR in how this kind soul creates/builds his wheels. So I'm going to use python 3.5 for now as i do not have numpy 1.11.1+mkl for python 3.6.
Yours sincerely

Resources