in the THONNY IDE
Check path
>>> import sys
>>> print (sys.path)
[”, ‘/lib’, ‘/’]
>>>
Wrote 3 modules:
lib/test_lib1.py
——————-
def test_libs():
print(__name__)
print(‘inside package lib/test_lib1’)
test_lib.py
————–
def test_libs():
print(__name__)
print(‘inside module test_lib’)
test_main.py
——————
import test_lib
#import lib.test_lib1
print (__name__)
test_lib.test_libs()
#lib.test_lib1.test_libs()
try to use external module
———————————–
>>> %upload test_lib.py test_lib.py
>>> %upload ‘lib\test_lib1.py’ test_lib1.py
>>> %upload test_main.py main.py
>>> %Run test_main.py
builtins
inside test_lib
>>>
change
test_main.py
——————
#import test_lib
import lib.test_lib1
print (__name__)
#test_lib.test_libs()
lib.test_lib1.test_libs()
try to use external package, in folder ./lib/ place empty __init.py__
>>> %upload test_main.py main.py
>>> %Run test_main.py
Traceback (most recent call last):
File “C:\Users\Admin\Documents\Python\workSpace\test_main.py”, line 2, in <module>
ImportError: no module named ‘lib’
>>>
whats wrong?