# import custom "module" - file location?

**URL:** <https://forums.openmv.io/t/import-custom-module-file-location/960>\
**Category:** OpenMV Boards\
**Created:** [October 23, 2018, 12:57am UTC](https://forums.openmv.io/t/import-custom-module-file-location/960 "2018-10-23T00:57:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![type11969](https://avatars.discourse-cdn.com/v4/letter/t/f08c70/32.png) [@type11969](https://forums.openmv.io/u/type11969)\
**Post date:** [October 23, 2018, 12:57am UTC](https://forums.openmv.io/t/import-custom-module-file-location/960/1 "2018-10-23T00:57:10Z")

</div>

Greetings. Apologies in advance, I have some C programming background but I am a complete newbie to python. I am trying to do something simple - I’m trying to organize my project in to separate files much like I usually do with my C based projects. But for whatever reason, I cannot get the “import” functionality to work for a file I’ve created. I suspect that it has something to do with my file location or something simple I am missing in a file header, etc. I have a basic file named test.py with a simple function in it (note that the excerpt below is literally all I have in the file).

```python
def testFunction:
    print("test")

```

In the same directory, I have another simple file named test\_main:

```python
import sensor, image, time, test

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)

clock = time.clock()

while(True):
    clock.tick()
    img = sensor.snapshot()
    print(clock.fps())

```

When I try to run test\_main, I get an ImportError: No module named ‘test’.

Both files are in the same directory. Originally they were not in the OpenMV folder in “mydocuments”, but I tried relocating them there with no success. So what am I missing? Has to be something simple/stupid. My understanding is that per ~feb of this year, the openmv ide supported importing like this - am I mistaken?

Rapid feedback appreciated - thanks!

-Chris

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [October 23, 2018, 5:47am UTC](https://forums.openmv.io/t/import-custom-module-file-location/960/2 "2018-10-23T05:47:17Z")

</div>

The OpenMV Cam compiles the code so the test.py file had to be on its flash drive. OpenMV IDE doesn’t actually do anything other than act as an editor and debug window.

That said, the IDE is quite smart and if you have that test.py file in the OpenMV folder in my documents OpenMV IDE will find it and ask if you’d like to copy it to the camera.

---

<div class="post-metadata">

**Author:** ![type11969](https://avatars.discourse-cdn.com/v4/letter/t/f08c70/32.png) [@type11969](https://forums.openmv.io/u/type11969)\
**Post date:** [October 23, 2018, 6:50pm UTC](https://forums.openmv.io/t/import-custom-module-file-location/960/3 "2018-10-23T18:50:07Z")

</div>

Thanks. If I make a change to test.py, I do get prompted with the following - Module test on your OpenMV Cam is different than the copy on your computer. Would you like OpenMV IDE to update the module on your Open MV Cam?  
If I click yes, I then get the same error - ImportError: no module named ‘test’.  
So its odd, OpenMV can find the test.py file, but there is still some sort of import error. Any ideas?

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [October 23, 2018, 9:13pm UTC](https://forums.openmv.io/t/import-custom-module-file-location/960/4 "2018-10-23T21:13:46Z")

</div>

Can you confirm the test.py module was copied over to your OpenMV Cam’s disk? Note that windows caches writes so it make take a second for the file to actually make it to the device.

---

<div class="post-metadata">

**Author:** ![type11969](https://avatars.discourse-cdn.com/v4/letter/t/f08c70/32.png) [@type11969](https://forums.openmv.io/u/type11969)\
**Post date:** [October 23, 2018, 9:49pm UTC](https://forums.openmv.io/t/import-custom-module-file-location/960/5 "2018-10-23T21:49:19Z")

</div>

Just to confirm, “disk” is referring to the folder that pops up upon physical USB connection, correct? If so, then no, I do not see test.py carried over to this folder. In fact, if I use the “save open script to openMV cam” command, I don’t see test\_main.py saved to this folder either. So apparently the problem is deeper than I thought. What would be preventing file transfer to the OpenMV cam? Certainly I can run new scripts through the IDE without issue.

Thanks for the help!

-Chris

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [October 25, 2018, 8:42pm UTC](https://forums.openmv.io/t/import-custom-module-file-location/960/6 "2018-10-25T20:42:30Z")

</div>

Hmm, I think the IDE then has bound itself to the wrong disk. In the next firmware release we bind the IDE to a particular disk name.

So, check the drive in OpenMV IDE (on the status bar) that OpenMV IDE thinks is the disk. It mostly guessed wrong.

In the next release we’ve made this better.

---

<div class="post-metadata">

**Author:** ![type11969](https://avatars.discourse-cdn.com/v4/letter/t/f08c70/32.png) [@type11969](https://forums.openmv.io/u/type11969)\
**Post date:** [October 29, 2018, 9:02pm UTC](https://forums.openmv.io/t/import-custom-module-file-location/960/7 "2018-10-29T21:02:27Z")

</div>

Thanks, I moved to my backup OpenMV cam which didn’t have the same issue, I’ll check the drive the next time I use the other cam.

---

<div class="post-metadata">

**Author:** ![jay.cross.bee](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/jay.cross.bee/32/2648_2.png) [@jay.cross.bee](https://forums.openmv.io/u/jay.cross.bee)\
**Post date:** [April 13, 2024, 12:04am UTC](https://forums.openmv.io/t/import-custom-module-file-location/960/8 "2024-04-13T00:04:10Z")

</div>

I know this post is old, but I’m having a similar issue. I found that there is a delay after saving an edit to the camera’s disk. It takes about 20 seconds after saving, the red light comes on again. During that time I can import a module stored on the camera.

It’s frustrating, though, that it takes so long. Is there something that I’m doing wrong?

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [April 13, 2024, 12:17am UTC](https://forums.openmv.io/t/import-custom-module-file-location/960/9 "2024-04-13T00:17:07Z")

</div>

If you are writing to the flash onboard, then yes. You need to use an SD card if you want fast saving.

The flash onboard has a really long erase time. It’s just the nature of QUADSPI chips. If you check the block erase time it’s on the order of hundreds of milliseconds.

SD cards are faster at this because they abstract the flash away from the interface and do a lot of magic internally to hide erase times.
