Installing libraries on ESP32

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
guyd
Posts: 81
Joined: Fri Jul 20, 2018 6:08 am

Installing libraries on ESP32

Post by guyd » Tue Jul 24, 2018 4:48 am

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

User avatar
pythoncoder
Posts: 4573
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Installing libraries on ESP32

Post by pythoncoder » 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.
Peter Hinch

guyd
Posts: 81
Joined: Fri Jul 20, 2018 6:08 am

Re: Installing libraries on ESP32

Post by guyd » Tue Jul 24, 2018 6:58 am

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
?

User avatar
pythoncoder
Posts: 4573
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Installing libraries on ESP32

Post by pythoncoder » 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.
Peter Hinch

guyd
Posts: 81
Joined: Fri Jul 20, 2018 6:08 am

Re: Installing libraries on ESP32

Post by guyd » Tue Jul 24, 2018 4:41 pm

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

User avatar
pythoncoder
Posts: 4573
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Installing libraries on ESP32

Post by pythoncoder » 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?
Peter Hinch

guyd
Posts: 81
Joined: Fri Jul 20, 2018 6:08 am

Re: Installing libraries on ESP32

Post by guyd » Tue Jul 24, 2018 5:48 pm

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 ?

User avatar
pythoncoder
Posts: 4573
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Installing libraries on ESP32

Post by pythoncoder » Wed Jul 25, 2018 4:04 am

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.
Peter Hinch

guyd
Posts: 81
Joined: Fri Jul 20, 2018 6:08 am

Re: Installing libraries on ESP32

Post by guyd » Wed Jul 25, 2018 4:42 am

right- so I have ESP32 connected, and using rshell successfully to connect ot it.
next step - enter repl and use upip to install?

User avatar
pythoncoder
Posts: 4573
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Installing libraries on ESP32

Post by pythoncoder » Wed Jul 25, 2018 4:46 am

If you've connected the ESP to the internet it should work.
Peter Hinch

Post Reply