Can't import original modules (pyb, time, Pin, etc)
Can't import original modules (pyb, time, Pin, etc)
Hi everybody!
This is my very first post, and let me apologise for my weak english capabilities.
Last day, I've tried to import my module to the main script. Of course I couldn't.
I've decided to find the relevant topic here, and I got what I want, but then something really weird happened:
I checked the sys.path, but not modified it, then I reset the pyboard (and exeptionally it was a hard reset).
When connected again to my computer, I started to rewrite my main script importing the pyb modul and from pyb the Pin and the ExtInt.
When I was trying to run the main.py I got Syntax error for the first two lines (containing the import arguments)... and since than I always get a syntax error if I try to import a base module.
The really strange is to me that if I type it directly to the REPL it works fine. Pls help me, "I sit on needles"!
This is my very first post, and let me apologise for my weak english capabilities.
Last day, I've tried to import my module to the main script. Of course I couldn't.
I've decided to find the relevant topic here, and I got what I want, but then something really weird happened:
I checked the sys.path, but not modified it, then I reset the pyboard (and exeptionally it was a hard reset).
When connected again to my computer, I started to rewrite my main script importing the pyb modul and from pyb the Pin and the ExtInt.
When I was trying to run the main.py I got Syntax error for the first two lines (containing the import arguments)... and since than I always get a syntax error if I try to import a base module.
The really strange is to me that if I type it directly to the REPL it works fine. Pls help me, "I sit on needles"!
Last edited by Trönfstar on Fri Jun 09, 2017 1:45 pm, edited 1 time in total.
Re: Can't import original modules (pyb, time, Pin, etc)
I forgot to notice, that afterall I made a factory reset using the buttons on the board, but nothing changed.
Re: Can't import original modules (pyb, time, Pin, etc)
Just arrived from work. Long time without power supply solved my issue.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Can't import original modules (pyb, time, Pin, etc)
This has me baffled.
As a general point it's best to put your code in a file other than main.py. Then, at the REPL, you can issueto debug it.
Once you have it working, edit main.py to issue
As a general point it's best to put your code in a file other than main.py. Then, at the REPL, you can issue
Code: Select all
import myfile
Once you have it working, edit main.py to issue
Code: Select all
import myfile
myfile.main() # Or whatever is needed to run it
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Can't import original modules (pyb, time, Pin, etc)
Thanks the tip! I'll put it to the proof.
Re: Can't import original modules (pyb, time, Pin, etc)
Also, please show us the code that doesn't work. Maybe it really has syntax errors in it.
Re: Can't import original modules (pyb, time, Pin, etc)
Since then it works fine. Actually it was a simple control of the integrated leds. What should I do to share my script in the future?
( I mean the frames around the posted codes) Both of you are very helpful. I appreciate that, thank you!
( I mean the frames around the posted codes) Both of you are very helpful. I appreciate that, thank you!
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Can't import original modules (pyb, time, Pin, etc)
Because of spam, the forum disallows formatting such as code blocks until you've made a certain number of posts.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Can't import original modules (pyb, time, Pin, etc)
Thanks the explanation!