Page 2 of 2

Re: Installing libraries on ESP32

Posted: Fri Jul 27, 2018 12:19 pm
by guyd
pythoncoder wrote:
Tue Jul 24, 2018 5:59 am
You should be able to install it using upip as described. What happens when you try?

Alternatively just copy datetime.py from micropython-lib to the ESP32: this should work as it's a simple library comprising just that one file. I have a clone of micropython-lib on my local hardware for such purposes.

Copied to root directory of pyboard, and got this message;

Code: Select all

>>> import datetime
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
MemoryError: memory allocation failed, allocating 136 bytes
>>> 

Re: Installing libraries on ESP32

Posted: Sat Jul 28, 2018 6:52 am
by pythoncoder
I hadn't spotted how big datetime.py is. Looking at the code it's the CPython 3.5 version, lightly modified. There is a case for a "micro" subset to be written.

If it's throwing a memory error on import immediately after a boot, it's too big for the target's RAM. Your best hope is to cross-compile it and copy the datetime.mpy to the target. Failing that you'll need to use frozen bytecode. Or use an ESP32 with SPIRAM and the Loboris port.

I suppose a last resort is to roll your own alternative by stripping out any functionality you don't need.

Re: Installing libraries on ESP32

Posted: Thu Aug 02, 2018 11:19 am
by guyd
Hi,
I try again to use datetime.py library ( after reflashing MicroPython again ).
As you suggested before - just copied datetime.py to ESP32 main directory.

additional services loaded: 1) wifi connection, 2)update RTC, both went successfully.

now again when I try to import datetime- I get a memery allocation err, as show before.

Can you explain what do I do wrong ?

Guy

Re: Installing libraries on ESP32

Posted: Thu Aug 02, 2018 12:28 pm
by SpotlightKid
Nothing. pythoncoder already explained to you what is going on in his last reply in the second paragraph.

Please read this for further explanation: http://docs.micropython.org/en/latest/e ... ained.html

Re: Installing libraries on ESP32

Posted: Thu Aug 02, 2018 1:09 pm
by Roberthh
@pythoncoder:
Or use an ESP32 with SPIRAM and the Loboris port.
The micropython.org port also supports SPIRAM. https://github.com/micropython/micropyt ... 092ee354b0

Re: Installing libraries on ESP32

Posted: Sun Oct 18, 2020 4:18 pm
by zelezni
This is rather old post, but hopefully my answer will prevent someone to spend "hours" looking for a solution (as I just did):

I am on Windows. In command prompt first navigate to a folder, where you've installed rshell. Activate it and enter repl. Then:

Code: Select all

import upip
upip.install('<desired_package_name>')
Example:

Code: Select all

upip.install('urllib.parse')
So, you are installing module directly on the board. Note that board needs to be connected to the internet for this to work.


Happy coding!

Re: Installing libraries on ESP32

Posted: Thu Oct 22, 2020 2:32 am
by MrR^2
Hello,
Another way to get an easy repl on Windows is to use UPycraft.
~MrR^2