May-24-2023, 05:42 PM
You must import sys first.
function on a different tab ?
|
May-24-2023, 05:42 PM
You must import sys first.
May-24-2023, 05:58 PM
(This post was last modified: May-27-2023, 10:58 AM by Larz60+.
Edit Reason: added code tags. Please see 'bbcode' on help page
)
i have now:
import sys import os if '__file__' not in globals(): __file__ = sys.modules[__name__].__file__ print('Cwd is {}'.format(os.getcwd())) print('Current program is {}'.format(__file__)) print('Sys.path is {}'.format(sys.path)) import examplemodresult:
May-24-2023, 06:31 PM
May-24-2023, 06:39 PM
i'm reading it already, tnx.
May-24-2023, 06:55 PM
(This post was last modified: May-24-2023, 06:55 PM by Gribouillis.)
Then you could perhaps just add the correct path to the directory containing the modules in sys.path, perhaps
import sys sys.path.append('/modules')at the top of maintest.py (or should it be 0:/modules ?)Also better uninstall that micropython-pathlib module that you installed. Not sure what it is.
May-24-2023, 06:56 PM
the article says:
>>> import sys >>> sys.path ['0:/', '0:/lib'] and i get: >>> import sys >>> sys.path ['', '.frozen', '/lib'] then: So lets create a file, mod1.py which contains the following: def hello(): print('hello from mod1') and copy it to your internal flash copy to your internal flash.....how to do that ? just: save as
May-24-2023, 07:06 PM
(This post was last modified: May-24-2023, 07:12 PM by deanhystad.)
These are pico questions. Maybe you will have better luck on a pico forum?
https://forums.raspberrypi.com/viewforum.php?f=143 BTW, I am sorry for earlier bad advice. I forgot that you were using micropython on a pico. The easiest route might be to use one file. I have no idea how to install modules on your device. I played with micropython on the LEGO Spike controller, and installing modules on that is a pain. I would write everything in one file, and after rigorous testing, I might pull out some of the code and install it as a module.
maybe i have to uninstall thonny, and then install again ?
edit: yes,..maybe i have to ask my question on the pico forum. thanks for so far.
May-26-2023, 05:18 PM
May-26-2023, 05:54 PM
(This post was last modified: May-26-2023, 05:54 PM by Gribouillis.)
|
|