Code: Select all
Traceback (most recent call last):
File "1:/main.py", line 2, in <module>
ImportError: No module named 'mymodule'
Code: Select all
Traceback (most recent call last):
File "1:/main.py", line 2, in <module>
ImportError: No module named 'mymodule'
Code: Select all
def mod1():
print('mod1')
Code: Select all
def mod2():
print('mod2')
Code: Select all
>>> import mod1
>>> mod1.mod1()
mod1
>>> import mod2
>>> mod2.mod2()
mod2
Code: Select all
807 >ls -lR /media/dhylands/4421-0000/
/media/dhylands/4421-0000/:
total 6
-rw-r--r-- 1 dhylands dhylands 279 Jan 1 00:00 boot.py
-rw-r--r-- 1 dhylands dhylands 33 Jan 1 00:00 main.py
-rw-r--r-- 1 dhylands dhylands 30 May 16 11:46 mod1.py
drwx------ 2 dhylands dhylands 512 May 16 11:46 mod2/
-rw-r--r-- 1 dhylands dhylands 2436 Jan 1 00:00 pybcdc.inf
-rw-r--r-- 1 dhylands dhylands 529 Jan 1 00:00 README.txt
/media/dhylands/4421-0000/mod2:
total 1
-rw-r--r-- 1 dhylands dhylands 30 May 16 11:46 __init__.py
Code: Select all
>>> import sys
>>> sys.path
['0:/', '0:/lib']
Code: Select all
>>> import sys
>>> sys.path.append('1:/')
>>> import mod3
>>> mod3.mod3()
mod3
>>> import mod4
>>> mod4.mod4()
mod4
Done. I created http://wiki.micropython.org/Importing-Modules and put a link to it on http://wiki.micropython.org/Hometorwag wrote:@ dhylands:
Thanks for the very nice how-to. Would you mind to add this to the wiki?