BioSTEAMDevelopmentGroup / biosteam

The Biorefinery Simulation and Techno-Economic Analysis Modules; Life Cycle Assessment; Chemical Process Simulation Under Uncertainty
Other
179 stars 35 forks source link

import from biorefineries library leads to the attribute error. #16

Closed DmitryBachin closed 4 years ago

DmitryBachin commented 4 years ago

Describe the bug if I try to run: from biorefineries.lipidcane import system or from biorefineries.cornstover import system The output in jupyter notebook is:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-68-5aca82ca079b> in <module>
----> 1 from biorefineries.lipidcane import system

~/opt/anaconda3/lib/python3.7/site-packages/biorefineries/lipidcane/system.py in <module>
     11 from biosteam import units
     12 from biorefineries.lipidcane.tea import LipidcaneTEA
---> 13 from biorefineries.lipidcane.chemicals import (pretreatment_chemicals,
     14                                   ethanol_chemicals,
     15                                   biodiesel_chemicals)

~/opt/anaconda3/lib/python3.7/site-packages/biorefineries/lipidcane/chemicals.py in <module>
     42                                 formula="C6H10O5", # Glucose monomer
     43                                 MW=162.14,
---> 44                                 Hf=-975708.8)
     45 Hemicellulose = create_new_chemical('Hemicellulose',
     46                                     formula="C5H8O5", # Xylose monomer

~/opt/anaconda3/lib/python3.7/site-packages/biorefineries/lipidcane/chemicals.py in create_new_chemical(ID, phase, **constants)
     34 
     35 def create_new_chemical(ID, phase='s', **constants):
---> 36     solid = tmo.Chemical.blank(ID, phase=phase, **constants)
     37     lipidcane_chemicals.append(solid)
     38     return solid

~/.local/lib/python3.7/site-packages/thermosteam/_chemical.py in blank(cls, ID, CAS, phase_ref, phase, **data)
   1039         self.phase_ref = phase_ref or phase
   1040         self._CAS = CAS or ID
-> 1041         for i,j in data.items(): setfield(self, i , j)
   1042         return self
   1043 

AttributeError: 'Chemical' object has no attribute 'formula'

and in Pycharm Python console it is like this:

In[27]: from biorefineries.cornstover import system
> /Users/dim/.local/lib/python3.7/site-packages/thermosteam/base/thermo_model_handle.py(132)integrate_by_T()
-> for model in self.models:
(Pdb) >?

To Reproduce run the if I try to run: from biorefineries.lipidcane import system or from biorefineries.cornstover import system in jupyter notebook or in the PyCharm Python console

Expected behavior The one which is described in the documentation, for example, here.

Environment

yoelcortes commented 4 years ago

Thanks for submitting this issue! Seems like I forgot to update the setup requirement for the biorefineries package (:-/). Could you "pip install biorefineries==2.3.1" and check if you can import the biorefineries again?

DmitryBachin commented 4 years ago

Thank you for your help. It worked. I did it, also it seems I had to update numba. If it is the case, please check the dependency of the numba version

yoelcortes commented 4 years ago

I have numba in the setup requirements. Sometimes Python does cannot update numba due to some dependency issues, preventing BioSTEAM from updating. Many people don't realize their package did not update.

I guess you figured out how to update numba. But here is the solution I usually give to force install:

pip install --user --ignore-installed <package>