Use external libraries
-
Where can I find documentation for using/importing other libraries on my LoPy.
I want to use the Paho MQTT Python library. Should I put it somewhere in the /flash over ftp?I'm new to Pycom and the Python programming language but I'm an experienced developer in Java, C++, Arduino,... So if you can point me to any other valuable info to get me started please share!
Thx in advance!
-
Note that
/flash
and/flash/lib
are insys.path
by default. If you want to put your libraries somewhere else, don't for get to add that directory to your path in boot.py.import sys sys.path.append('/flash/custom-dir')
-
I think that /flash/lib folder is also right and logical place for external libraries. ;o)
-
Library is just another python file. If you put library.py into the same folder as the main.py you can than import it in the main.py file like this:
import library
and use objects in the library:
library.ExampleClass()