Page 1 of 1

Import error in File but not REPL

Posted: Thu Dec 16, 2021 9:49 pm
by Minyiky
Hi,

I am trying to set up a docker environment for running a micropython script, but am running into a strange issue,

I have built micropython and can enter the interactive repl and so i know micropython is working.

The issue I am facing is around importing modules, if I run a file using "micropython/ports/unix/micropython-dev imports.py" I get the following output:

Code: Select all

DL               imagetools        uasyncio/stream   upip_utarfile
__main__          lodepng           ubinascii         urandom
_thread           lv_timer          ubluetooth        ure
_uasyncio         lv_utils          ucollections      uselect
btree             lvgl              ucryptolib        usocket
builtins          math              uctypes           ussl
cmath             micropython       uerrno            ustruct
display_driver    termios           uhashlib          usys
display_driver_utils                uarray            uheapq            utime
evdev             uasyncio/__init__ uio               utimeq
fb                uasyncio/core     ujson             uwebsocket
ffi               uasyncio/event    umachine          uzlib
fs_driver         uasyncio/funcs    uos
gc                uasyncio/lock     upip
Plus any modules on the filesystem
None
Traceback (most recent call last):
  File "imports.py", line 4, in <module>
ImportError: no module named 'upip'
The script only contains 2 lines:

Code: Select all

print(help('modules'))
import upip
If however I start micropython in interactive mode I am able to import and use upip with no problems.

Has anyone else come accross something similar before?

Thanks