Having some trouble adding modules to my LoPy (with Expansion Board 2.0). In particular, one I am trying to add is (u)requests. If I take the urequests folder from https://github.com/micropython/micropython-lib and throw it in /flash/lib, I can import it, but urequests.<anything> (like urequests.get()) doesn't work, and dir(urequests) gives name and file only. Same thing if I put it on the micro sd card (with it mounted as /sd/ and that added to sys.path).
Rather than the folder itself, if I paste the files from inside it into /flash/lib, dir(urequests) shows all of urequest's functions. While this lets me use it, it doesn't let me add other modules, as they'll each have a setup.py.
Do I need to add the folder from each module I add to sys.path (e.g. /flash/lib/urequests, /flash/lib/ssl, ..., etc.)? I have searched around quite a bit and didn't see anything saying that is the right way to do it. On the contrary, the first way I tried seemed to be the prescribed method.
Thank you for the assistance.
@netskink the following command works for me though:
import sys sys.path.append("/flash/test") import test_x
@cpyree, the copy of the urequests forlder in /flash/lib is correct. May be, since the urequests forlder does not have _init_.py file, you need to import it as:
import urequests.urequests as urequests urequests.get(...)
@cpyree I tried to add a tests folder and put files in there. I did something like this
# Add test dir path sys.path.insert(0, "/test") import test_x
Sadly this failed. Any idea how to do something like this?