Import error in File but not REPL

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
Minyiky
Posts: 32
Joined: Sat Oct 24, 2020 5:53 pm

Import error in File but not REPL

Post by Minyiky » Thu Dec 16, 2021 9:49 pm

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

Post Reply