# ImportError Cython

**URL:** <https://brian.discourse.group/t/importerror-cython/958>\
**Category:** Support\
**Created:** [5 April 2023 15:20 UTC](https://brian.discourse.group/t/importerror-cython/958 "2023-04-05T15:20:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![caccola816](https://avatars.discourse-cdn.com/v4/letter/c/f17d59/32.png) [@caccola816](https://brian.discourse.group/u/caccola816)\
**Post date:** [5 April 2023 15:20 UTC](https://brian.discourse.group/t/importerror-cython/958/1 "2023-04-05T15:20:48Z")

</div>

# Description of problem

Hello, my script has worked fine until some days ago. I’m running a long simulation that usually lasts around 4-5 hours. But two days ago I started getting this message at around half of the simulation:  
ImportError: /home/federico/.cython/brian\_extensions/\_cython\_magic\_c77449a0304e7837cd91e0c29cc720e5.cpython-38-x86\_64-linux-gnu.so: failed to map segment from shared object brian

# What you have aready tried

I tried to reduce the simulation time at 100\*ms and it work without any problem. The problem arise only if I try to do it long. (The simulation time is 300 seconds)  
But with 300 seconds it worked fine until three days ago.

In this moment, I switched the codegen target in numpy, but I would like to keep generating the code in Cython..

I’m not sharing the code since it’s kinda long..

---

<div class="post-metadata">

**Author:** ![mstimberg](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/mstimberg/32/11_2.png) [@mstimberg](https://brian.discourse.group/u/mstimberg)\
**Post date:** [6 April 2023 08:29 UTC](https://brian.discourse.group/t/importerror-cython/958/2 "2023-04-06T08:29:07Z")

</div>

Hi @caccola816 I haven’t seen this error before, so I’m not sure where it is coming from. Is this the full error message or is there more information after it? Usually, I’d say an error that occurs for a long simulation but not for a short one would likely be a memory issue (i.e. you have monitors that take up too much space) – but that would be odd since you say it works with numpy which should have the same issue.  
When you say it worked until a few days ago, do you mean for the same code, same version of Brian, and same environment in general (dependencies, etc.)?

---

<div class="post-metadata">

**Author:** ![caccola816](https://avatars.discourse-cdn.com/v4/letter/c/f17d59/32.png) [@caccola816](https://brian.discourse.group/u/caccola816)\
**Post date:** [6 April 2023 09:12 UTC](https://brian.discourse.group/t/importerror-cython/958/3 "2023-04-06T09:12:25Z")

</div>

At the end it didn’t work with numpy too, so It is possible that it’s a memory issue. But yes I didn’t change neither the code or the versions, so that’s why I think it’s strange. Anyway I printed the time at which the process is terminated and it’s always the same, so probably it’s a memory issue…

---

<div class="post-metadata">

**Author:** ![rth](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/rth/32/16_2.png) [@rth](https://brian.discourse.group/u/rth)\
**Post date:** [6 April 2023 20:28 UTC](https://brian.discourse.group/t/importerror-cython/958/4 "2023-04-06T20:28:43Z")

</div>

@caccola816 if you run on Linux, open another terminal and run `top` or, even better, `htop`, then press `Shift-M` to sort processes by memory consumption.
