SBRG / MASSpy

https://masspy.readthedocs.io
MIT License
22 stars 6 forks source link

Import error involving numpy and cobra #173

Open CNelias opened 1 year ago

CNelias commented 1 year ago

When trying to import mass (or cobra), I get the following error:

ImportError: cannot import name 'object' from 'numpy' (C:\Users\Corentin offline\AppData\Roaming\Python\Python310\site-packages\numpy\__init__.py)

The full stack trace goes as follow:

C:\ProgramData\anaconda3\lib\site-packages\cobra\io\mat.py:13: FutureWarning: In the future `np.object` will be defined as the corresponding NumPy scalar.
  from numpy import object as np_object
Traceback (most recent call last):

  Cell In[2], line 1
    import mass

  File C:\ProgramData\anaconda3\lib\site-packages\mass\__init__.py:7
    from mass import enzyme_modules, io

  File C:\ProgramData\anaconda3\lib\site-packages\mass\enzyme_modules\__init__.py:2
    from mass.enzyme_modules.enzyme_module import EnzymeModule

  File C:\ProgramData\anaconda3\lib\site-packages\mass\enzyme_modules\enzyme_module.py:58
    from cobra.core.dictlist import DictList

  File C:\ProgramData\anaconda3\lib\site-packages\cobra\__init__.py:17
    from cobra import io

  File C:\ProgramData\anaconda3\lib\site-packages\cobra\io\__init__.py:6
    from cobra.io.mat import load_matlab_model, save_matlab_model

  File C:\ProgramData\anaconda3\lib\site-packages\cobra\io\mat.py:13
    from numpy import object as np_object

Any idea what's causing it and how I can fix this? I'm running Python 3.10 on windows 11. I have tried on another machine (also windows 11) and get the same error.

AlbanMariette commented 8 months ago

Hi @CNelias, did you find a fix for this issue? I some how have the same issue with MassPy, updating numpy and scipy does not fix the issue and updating Cobra to the last version does not work because of incompatibilities

CNelias commented 8 months ago

Unfortunately not, and I decided to switch to another framework at some point.

AlbanMariette commented 8 months ago

Hi @CNelias, thanks for your answer, may I ask to which framework you switched because I do not think COBRA would allow me to simulate enzyme inhibition or to integrate enzyme activities as MASSPY would have allowed me?

luciansmith commented 1 week ago

According to https://stackoverflow.com/questions/75069062/module-numpy-has-no-attribute-object, the 'object' child of numpy was removed in 1.24.0, so until masspy updates their code to match the new numpy, you'll need to install 1.23.5 or earlier (pip install numpy==1.23.5)