BioSTEAMDevelopmentGroup / biosteam

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

ModuleNotFoundError and TypeError in the TEA #18

Closed DmitryBachin closed 4 years ago

DmitryBachin commented 4 years ago

Describe the bug The attempt to reproduce documentation section TEA tea let to this output

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
~/.local/lib/python3.7/site-packages/lazypkg/__init__.py in __getattr__(self, name)
     52         try:
---> 53             attr = import_module('.'+name, self.__package__)
     54         except ModuleNotFoundError as Error:

~/opt/anaconda3/lib/python3.7/importlib/__init__.py in import_module(name, package)
    126             level += 1
--> 127     return _bootstrap._gcd_import(name[level:], package, level)
    128 

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _gcd_import(name, package, level)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _find_and_load(name, import_)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)

ModuleNotFoundError: No module named 'biorefineries.lipidcane.lipidcane_sys'

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-4-a199e55e7f85> in <module>
----> 1 lipidcane_tea = LipidcaneTEA(system=lc.lipidcane_sys,
      2                              IRR=0.15,
      3                              duration=(2018, 2038),
      4                              depreciation='MACRS7',
      5                              income_tax=0.35,

~/.local/lib/python3.7/site-packages/lazypkg/__init__.py in __getattr__(self, name)
     60             unsearchable = self.__unsearchable
     61             for i in self.__all__:
---> 62                 module = getattr(self, i)
     63                 if (isinstance(module, ModuleType)
     64                     and i not in unsearchable

~/.local/lib/python3.7/site-packages/lazypkg/__init__.py in __getattr__(self, name)
     51         attempts = self.__import_attempts
     52         try:
---> 53             attr = import_module('.'+name, self.__package__)
     54         except ModuleNotFoundError as Error:
     55             if name in attempts:

~/opt/anaconda3/lib/python3.7/importlib/__init__.py in import_module(name, package)
    125                 break
    126             level += 1
--> 127     return _bootstrap._gcd_import(name[level:], package, level)
    128 
    129 

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _gcd_import(name, package, level)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _find_and_load(name, import_)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _load_unlocked(spec)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap_external.py in exec_module(self, module)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

~/opt/anaconda3/lib/python3.7/site-packages/biorefineries/lipidcane/process_settings.py in <module>
     42          'Gasoline': 0.756} # 2 USD/gal
     43 
---> 44 set_lipidcane_process_settings()

~/opt/anaconda3/lib/python3.7/site-packages/biorefineries/lipidcane/process_settings.py in set_lipidcane_process_settings()
     15     bst.PowerUtility.price = 0.065
     16     HeatUtility = bst.HeatUtility
---> 17     steam_utility = HeatUtility.heating_agents['Low pressure steam']
     18     steam_utility.efficiency = 0.85
     19     steam_utility.T = 529.2

TypeError: list indices must be integers or slices, not str

To Reproduce First two steps from the TEA documentation (9.1 and the first step of 9.2)

Environment

yoelcortes commented 4 years ago

Fixed! There were some problems with versioning... again. This time I am making it so that if you update a lower level package like thermosteam, all higher level packages (e.g. biorefineries, and biosteam) are also updated. I actually wasn't doing this before thinking users may want control this (bad idea jaja).

Also, I found that depending on your version of numpy, your numba requirement may be different. So just in case, I also added the latest compatible versions of numpy and numba as requirements.

Also, if you find BioSTEAM useful, don't forget to "Star" it! ;)

DmitryBachin commented 4 years ago

Thank you very much!

It still has issues, but the output is different. I will share it a bit later when I check that it is not a problem from my side.

I will star it when I finish reproducing the documentation ;-)

yoelcortes commented 4 years ago

Cool. Here are few things to take note of:

DmitryBachin commented 4 years ago

Thank you! So the output:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
~/.local/lib/python3.7/site-packages/lazypkg/__init__.py in __getattr__(self, name)
     52         try:
---> 53             attr = import_module('.'+name, self.__package__)
     54         except ModuleNotFoundError as Error:

~/opt/anaconda3/lib/python3.7/importlib/__init__.py in import_module(name, package)
    126             level += 1
--> 127     return _bootstrap._gcd_import(name[level:], package, level)
    128 

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _gcd_import(name, package, level)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _find_and_load(name, import_)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)

ModuleNotFoundError: No module named 'biorefineries.lipidcane.lipidcane_sys'

During handling of the above exception, another exception occurred:

ModuleNotFoundError                       Traceback (most recent call last)
~/.local/lib/python3.7/site-packages/lazypkg/__init__.py in __getattr__(self, name)
     52         try:
---> 53             attr = import_module('.'+name, self.__package__)
     54         except ModuleNotFoundError as Error:

~/opt/anaconda3/lib/python3.7/importlib/__init__.py in import_module(name, package)
    126             level += 1
--> 127     return _bootstrap._gcd_import(name[level:], package, level)
    128 

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _gcd_import(name, package, level)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _find_and_load(name, import_)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _load_unlocked(spec)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap_external.py in exec_module(self, module)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

~/opt/anaconda3/lib/python3.7/site-packages/biorefineries/lipidcane/utils/__init__.py in <module>
      6 """
----> 7 from . import composition
      8 

~/opt/anaconda3/lib/python3.7/site-packages/biorefineries/lipidcane/utils/composition.py in <module>
     13 from biorefineries.lipidcane.system import lipid_cane
---> 14 from array_collections import tuple_array
     15 

ModuleNotFoundError: No module named 'array_collections'

During handling of the above exception, another exception occurred:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-3-a199e55e7f85> in <module>
----> 1 lipidcane_tea = LipidcaneTEA(system=lc.lipidcane_sys,
      2                              IRR=0.15,
      3                              duration=(2018, 2038),
      4                              depreciation='MACRS7',
      5                              income_tax=0.35,

~/.local/lib/python3.7/site-packages/lazypkg/__init__.py in __getattr__(self, name)
     60             unsearchable = self.__unsearchable
     61             for i in self.__all__:
---> 62                 module = getattr(self, i)
     63                 if (isinstance(module, ModuleType)
     64                     and i not in unsearchable

~/.local/lib/python3.7/site-packages/lazypkg/__init__.py in __getattr__(self, name)
     60             unsearchable = self.__unsearchable
     61             for i in self.__all__:
---> 62                 module = getattr(self, i)
     63                 if (isinstance(module, ModuleType)
     64                     and i not in unsearchable

~/.local/lib/python3.7/site-packages/lazypkg/__init__.py in __getattr__(self, name)
     54         except ModuleNotFoundError as Error:
     55             if name in attempts:
---> 56                 raise Error
     57             else:
     58                 attempts.add(name)

~/.local/lib/python3.7/site-packages/lazypkg/__init__.py in __getattr__(self, name)
     51         attempts = self.__import_attempts
     52         try:
---> 53             attr = import_module('.'+name, self.__package__)
     54         except ModuleNotFoundError as Error:
     55             if name in attempts:

~/opt/anaconda3/lib/python3.7/importlib/__init__.py in import_module(name, package)
    125                 break
    126             level += 1
--> 127     return _bootstrap._gcd_import(name[level:], package, level)
    128 
    129 

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _gcd_import(name, package, level)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _find_and_load(name, import_)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _load_unlocked(spec)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap_external.py in exec_module(self, module)

~/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

~/opt/anaconda3/lib/python3.7/site-packages/biorefineries/lipidcane/utils/__init__.py in <module>
      5 @author: yoelr
      6 """
----> 7 from . import composition
      8 
      9 __all__ = (*composition.__all__,)

~/opt/anaconda3/lib/python3.7/site-packages/biorefineries/lipidcane/utils/composition.py in <module>
     12 from biorefineries.lipidcane.chemicals import pretreatment_chemicals
     13 from biorefineries.lipidcane.system import lipid_cane
---> 14 from array_collections import tuple_array
     15 
     16 __all__ = ('set_lipid_fraction',)

ModuleNotFoundError: No module named 'array_collections'
yoelcortes commented 4 years ago

Fixed! You can "pip install biorefineries==2.4.1" and try again. "array_collections" is an old package I made. Didn't realize the lipidcane biorefinery still used it. I just removed all dependencies on that package. Thanks for posting!

yoelcortes commented 4 years ago

I'm assuming it worked. I'll be releasing BioSTEAM v2.5 in about two weaks with some power features on automatic creation of the complete system (with all internal recycles, process specifications, and facilities) and some extra documentation chapters with a complete biorefinery example. Hope you found BioSTEAM useful and can become an active user :)