Page 1 of 1

base64 module not found

Posted: Tue Mar 02, 2021 7:30 pm
by mflmartin
When I try to import base64 or ubase64, I get no module named base64:

Is there anything that have to be done in order to activate it? Thanks so much.

Code: Select all


MicroPython v1.13 on 2020-09-02; ESP32 module with ESP32
Type "help()" for more information.
>>> import base64
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'base64'
>>> import ubase64
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'ubase64'


Re: base64 module not found

Posted: Tue Mar 02, 2021 8:46 pm
by mflmartin
I guess that I needed to install it with upip, and I did, after connecting the module to the wifi.

But this brings me to the next question: What would be the best way to install it in a new device automatically? (Without having to buiild micropython from sources). I am guessing, maybe, checking if it exists in the boot.py or in the main process and install it if it doesn't, or is there another recommended way?

Thanks!

Re: base64 module not found

Posted: Wed Mar 03, 2021 5:41 am
by jimmo
mflmartin wrote:
Tue Mar 02, 2021 8:46 pm
But this brings me to the next question: What would be the best way to install it in a new device automatically? (Without having to buiild micropython from sources). I am guessing, maybe, checking if it exists in the boot.py or in the main process and install it if it doesn't, or is there another recommended way?
I guess your new device also needs to have main.py (and potentially other files) copied anyway.

With previous projects I've had a script (a Makefile) with two targets: deploy and update. So deploy does a "first install" and copies all relevant files to the device (using pyboard.py). update just copies my code (i.e. it assumes things like base64.py and other libraries don't change).

You could also take a look at rshell which has a way to synchronise the host directory with the target (without copying every file every time).

(I guess what I'm saying is that you should have a directory on your PC, probably in source control, that mirrors the fileystem layout of the device, and the question is really a matter of how to synchronise that directory to the device).