opencobra / cobrapy

COBRApy is a package for constraint-based modeling of metabolic networks.
http://opencobra.github.io/cobrapy/
GNU General Public License v2.0
465 stars 218 forks source link

[Question] "ImportError: No module named" fva error #846

Closed donghyukPDSE closed 5 years ago

donghyukPDSE commented 5 years ago

Problem description

fva question!

I'm really first time to use cobrapy and python. While I'm trying to do fva, there is problem with invalid argument and " ImportError: No module named " I think I probably did not understand language of python, but I cannot fix it.. It would be pleasure to help me! Thank you!

Code Sample

model = cobra.io.read_sbml_model( "iJO1366.xml") fva = flux_variability_analysis(model)

by using pycharm, 2.7 python

Actual Output

Traceback (most recent call last): File "", line 1, in File "C:\Python27\Lib\multiprocessing\forking.py", line 380, in main prepare(preparation_data) File "C:\Python27\Lib\multiprocessing\forking.py", line 504, in prepare file, path_name, etc = imp.find_module(main_name, dirs) ImportError: No module named Traceback (most recent call last): File "", line 1, in File "C:\Users\cdh12\PycharmProjects\untitled3\venv\lib\site-packages\cobra\flux_analysis\variability.py", line 187, in flux_variability_analysis initargs=(model, loopless, what[:3]) File "C:\Python27\Lib\multiprocessing__init.py", line 232, in Pool return Pool(processes, initializer, initargs, maxtasksperchild) File "C:\Python27\Lib\multiprocessing\pool.py", line 161, in init__ self._repopulate_pool() File "C:\Python27\Lib\multiprocessing\pool.py", line 225, in _repopulate_pool w.start() File "C:\Python27\Lib\multiprocessing\process.py", line 130, in start self._popen = Popen(self) File "C:\Python27\Lib\multiprocessing\forking.py", line 280, in init to_child.close() IOError: [Errno 22] Invalid argument

cobra | 0.15.3 | 0.15.3 depinfo | 1.5.1 | 1.5.1 future | 0.17.1 | 0.17.1 input | 0.0.0 | 0.0.0 mpmath | 1.1.0 | 1.1.0 numpy | 1.16.3 | 1.16.3 optlang | 1.4.4 | 1.4.4 pandas | 0.24.2 | 0.24.2 pip | 19.1.1 | 19.1.1 pipdeptree | 0.13.2 | 0.13.2 python-dateutil | 2.8.0 | 2.8.0 python-libsbml-experimental | 5.18.0 | 5.18.0 pytz | 2019.1 |   ruamel.ordereddict | 0.4.13 |   ruamel.yaml | 0.15.94 |   setuptools | 41.0.1 |   six | 1.12.0 |   swiglpk | 4.65.0 |   sympy | 1.4 |   tabulate | 0.8.3 |   wheel | 0.33.1 |  
taylo5jm commented 5 years ago

I believe this might be an issue with the way that parallel processing in Python differs between windows and Unix systems. I'm not sure if the flux_variability_analysis function will work with the default arguments if you are using it interactively on windows, because the default settings will try to use more than one CPU.

If you are using the function in the python console, try to set processes=1. If your model is small, processing in serial might be OK.

model = cobra.io.read_sbml_model( "iJO1366.xml")   
fva = flux_variability_analysis(model, processes=1)    

I think you might be able to run this code in parallel if you were to write a script and run the script from the command-line. I'm not sure if this will work, but it might :) Save the following code to a file called fva_test.py and try python fva_test.py from the command-line.

# fva_test.py
if __name__ == '__main__':  
    model = cobra.io.read_sbml_model( "iJO1366.xml")   
    fva = flux_variability_analysis(model, processes=2)  
donghyukPDSE commented 5 years ago

Thank you Soooooo MUCH!!!:) Oh and also the explanation of mulitprocessing. Thank you for helping me to figure it out.