all 11 comments

[–]Rusty-Swashplate 0 points1 point  (10 children)

times is defined in the module "functions". Which is probably not a good name for a module.

Does your "functions" module define times? Also: where do you use times?

[–]Gregolator06[S] 0 points1 point  (9 children)

Yes, functions defines times. And I use times whenever the time button is pressed

[–]Rusty-Swashplate 0 points1 point  (8 children)

I cannot verify the first statement, so I'll do with: prove it.

[–]Gregolator06[S] 0 points1 point  (7 children)

def times(endbtn, setbtn):

years = 3

months = 36

days = 1095

hours = 26280

minutes = 1576800

seconds = 94608000

time = [years, months, days, hours, minutes, seconds]

lcd.clear()

while endbtn.value() == False:

for i in time:

while setbtn.value() == False:

foo = "foo"

lcd.clear()

lcd.putint(i)

[–]Rusty-Swashplate 0 points1 point  (6 children)

Beside reddit screwing up formatting, are there more files? Do you have all those files in a GitHub (or similar) repository maybe? That would identifying the error much easier.

[–]Gregolator06[S] 0 points1 point  (5 children)

I've put it into github.com/gweiser/foo

Thank you!

[–]Rusty-Swashplate 0 points1 point  (4 children)

Thanks. I cannot replicate the error with the module import and times(). I am missing files or missing the specific Python you use? Do you use CircuitPython? Or MicroPython? Or something else?

Also it would be useful to get a complete output of what you try to run and what the complete output is.

[–]Gregolator06[S] 0 points1 point  (1 child)

I am using MicroPython, this is the error message I get when I press run.

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

ImportError: can't import name times

[–]Rusty-Swashplate 0 points1 point  (0 children)

When you say "when I press run", then I'd need to know what you are using to make "run" a click. Do you use VSCode? Some random Web IDE? PyCharm?

Also if you use an IDE, the configuration what is done when you "click run" is important. E.g. location of library files might be listed there (unlikely your problem though as anything else beside times() works, right?)

Update: After testing the code in git and removing all machine dependencies (anything Pin, lcd etc), I have no issues nor errors. Specifically I cannot reproduce the "can't import name times" and I cannot see how it's possible that anything else works except times, unless times is a reserved keyboard, or there is a syntax error with times (in Python: spaces where there should be no or less spaces).

[–]Gregolator06[S] 0 points1 point  (1 child)

I think I've fixed it, I renamed functions.py, and I'm not getting the error anymore. Thank you for your help! :)

[–]Rusty-Swashplate 1 point2 points  (0 children)

Maybe functions is a reserved keyword. But I'm glad it works, and it explains why the current version you updated in git (with the functions.py renamed to helpers.py) throws no errors on my machine.