sqlite3.OperationalError: disk I/O error

22 views
Skip to first unread message

Jamie Stankiewiz

unread,
Dec 24, 2024, 1:49:37 PM12/24/24
to cobr...@googlegroups.com
Hi there!!

I am new to cobrapy and tried to load a simple model to get started. Below is my code that I ran. Immediately, I got a sqlite3 disk error and I am wondering what the underlying issues is and how I can fix this? Thank you in advanced!!

 

Test.py:

 

import cobra

from cobra.io import load_model

model = load_model("textbook")

 

Traceback:

 

Traceback (most recent call last):

  File "/test.py", line 5, in <module>

    model = load_model("textbook")

  File "/.local/lib/python3.9/site-packages/cobra/io/web/load.py", line 88, in load_model

    data = _cached_load(

  File "/.local/lib/python3.9/site-packages/cobra/io/web/load.py", line 121, in _cached_load

    with diskcache.Cache(

  File "/.local/lib/python3.9/site-packages/diskcache/core.py", line 478, in __init__

    self.reset(key, value, update=False)

  File "/.local/lib/python3.9/site-packages/diskcache/core.py", line 2431, in reset

    ((old_value,),) = sql(

sqlite3.OperationalError: disk I/O error

 

 

 

Thank you for the help!
Jamie

 

Joshua Lerman

unread,
Dec 24, 2024, 3:59:28 PM12/24/24
to Jamie Stankiewiz, cobr...@googlegroups.com
Hi Jamie,

Remember me?  I can confirm your code is absolutely fine. I think the error is more about where you are running the code and if there is some sort of permissions error.

From your desktop:

# Create a new virtual environment
python -m venv cobra_env

# Activate the virtual environment
# For Windows:
cobra_env\Scripts\activate
# For macOS/Linux:
source cobra_env/bin/activate

# Install cobrapy
pip install cobra

Then try running test.py on your desktop.

Please write back if you have difficulties. This page may also be useful for you https://github.com/opencobra/cobrapy/blob/devel/INSTALL.rst


Best,
Josh

--
You received this message because you are subscribed to the Google Groups "cobra pie" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cobra-pie+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/cobra-pie/CAFkhkVTfVHi6B2AwjC6K6Peja7sdef-VDKE-kRMg%2BTKCVcpX-w%40mail.gmail.com.

Jamie Stankiewiz

unread,
Dec 24, 2024, 4:24:45 PM12/24/24
to Joshua Lerman, cobr...@googlegroups.com

Wow, Josh Lerman - hi!!
Hope you are well!

Thanks for the feedback here. I suspected this has to be related to a vm issue that I'm running this code on. I'll reply back if there's more issues that come up.

Happy holidays!!
Jamie

Matthias König

unread,
Jan 8, 2025, 5:30:22 AMJan 8
to Jamie Stankiewiz, Joshua Lerman, cobr...@googlegroups.com
Just try this in a clean virtual environment (e.g. created with uv). Also I recommend using a more up to date python version such as py3.12.
I had no issues loading the model in a clean test environment:

```
mkoenig@mklab:~/Downloads/test_cobrapy$ uv venv --python 3.12
Using CPython 3.12.8 interpreter at: /usr/bin/python3.12
Creating virtual environment at: .venv
Activate with: source .venv/bin/activate

mkoenig@mklab:~/Downloads/test_cobrapy$ uv pip install cobra
Resolved 34 packages in 553ms
Prepared 15 packages in 4.19s
Installed 34 packages in 44ms
 + annotated-types==0.7.0
 + anyio==4.8.0
 + appdirs==1.4.4
 + certifi==2024.12.14
 + cobra==0.29.1
 + depinfo==2.2.0
 + diskcache==5.6.3
 + future==1.0.0
 + h11==0.14.0
 + httpcore==1.0.7
 + httpx==0.28.1
 + idna==3.10
 + importlib-resources==6.5.2
 + markdown-it-py==3.0.0
 + mdurl==0.1.2
 + mpmath==1.3.0
 + numpy==2.2.1
 + optlang==1.8.2
 + pandas==2.2.3
 + pydantic==2.10.4
 + pydantic-core==2.27.2
 + pygments==2.19.1
 + python-dateutil==2.9.0.post0
 + python-libsbml==5.20.4
 + pytz==2024.2
 + rich==13.9.4
 + ruamel-yaml==0.18.10
 + ruamel-yaml-clib==0.2.12
 + six==1.17.0
 + sniffio==1.3.1
 + swiglpk==5.0.12
 + sympy==1.13.3
 + typing-extensions==4.12.2
 + tzdata==2024.2

mkoenig@mklab:~/Downloads/test_cobrapy$ source .venv/bin/activate

(test_cobrapy) mkoenig@mklab:~/Downloads/test_cobrapy$ python
Python 3.12.8 (main, Dec  4 2024, 08:54:13) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> import cobra
>>> from cobra.io import load_model
>>> model = load_model("textbook")
>>> model
<Model e_coli_core at 0x7f59c07f6630>
```


Reply all
Reply to author
Forward
0 new messages