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!
-
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()
-
I think that /flash/lib folder is also right and logical place for external libraries. ;o)
-
Note that
/flashand/flash/libare insys.pathby 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')
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login