Page 1 of 2

Installing libraries on ESP32

Posted: Tue Jul 24, 2018 4:48 am
by guyd
Hi,
I'm interested in installing additional module from https://github.com/micropython/micropython-lib
but- I guess I don't understand explanation at the bottom of the page.

im looking for - `datetime` replacement

Guy

Re: Installing libraries on ESP32

Posted: Tue Jul 24, 2018 5:59 am
by pythoncoder
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.

Re: Installing libraries on ESP32

Posted: Tue Jul 24, 2018 6:58 am
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.
1) I was copied that spcific file, which raised an error running it (placed in datetime directory )

Code: Select all

>>> import datetime.datetime
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
MemoryError: memory allocation failed, allocating 136 bytes
>>> 
2) didn't understand the syntax : where to type

Code: Select all

micropython -m upip install micropython-pystone
?

Re: Installing libraries on ESP32

Posted: Tue Jul 24, 2018 12:35 pm
by pythoncoder
1. I suggest trying again without using a datetime directory. To use a directory structure you need to understand Python packages and __init__.py.

2. That invocation line is to install to a PC under the Unix build.

Re: Installing libraries on ESP32

Posted: Tue Jul 24, 2018 4:41 pm
by guyd
pythoncoder wrote:
Tue Jul 24, 2018 12:35 pm
1. I suggest trying again without using a datetime directory. To use a directory structure you need to understand Python packages and __init__.py.

2. That invocation line is to install to a PC under the Unix build.
1. succeeded. can you adress to syntax examples ?
2. still don't understand. Is this some kind of a build under linux ? when i try upip under repl - it does not succeed

Re: Installing libraries on ESP32

Posted: Tue Jul 24, 2018 5:41 pm
by pythoncoder
Python packages are a very long established feature of the Python language and are not MicroPython specific. I suggest a book or online tutorial on the language.

If you have an ESP32 connected to the internet you should be able to use upip. What invocation line are you using and what error message do you see?

Re: Installing libraries on ESP32

Posted: Tue Jul 24, 2018 5:48 pm
by guyd
pythoncoder wrote:
Tue Jul 24, 2018 5:41 pm
Python packages are a very long established feature of the Python language and are not MicroPython specific. I suggest a book or online tutorial on the language.

If you have an ESP32 connected to the internet you should be able to use upip. What invocation line are you using and what error message do you see?
I use Python for the past year and I know how to work with PIP using Linux. On Linux I type PIP command using terminal. Now on Micropython you don't have a command line as in Linux .... so when I want to install any upip package from the internet ( say dataetime for example )- how and where do you exactly type those commands ?
repl ? rshell ?

Re: Installing libraries on ESP32

Posted: Wed Jul 25, 2018 4:04 am
by pythoncoder
You get a command line by linking the ESP32 to a PC using a USB cable and running a terminal emulator on the PC. If you're using Linux I recommend rshell. I'm not well up on other OS's, but I gather Windows users recommend Putty if rshell gives problems.

Re: Installing libraries on ESP32

Posted: Wed Jul 25, 2018 4:42 am
by guyd
right- so I have ESP32 connected, and using rshell successfully to connect ot it.
next step - enter repl and use upip to install?

Re: Installing libraries on ESP32

Posted: Wed Jul 25, 2018 4:46 am
by pythoncoder
If you've connected the ESP to the internet it should work.