Page 1 of 1
Python tools fail with "ImportError: No module named IDF"
Posted: Tue Nov 19, 2019 7:35 pm
by jhubbardsf
Some of the tools fail with a "ImportError: No module named IDF" error. Specifically right now while running the example_test.py script used in simple_ota_example. I'm sure there's something really simple I'm missing but couldn't figure out what step I missed.
Re: Python tools fail with "ImportError: No module named IDF"
Posted: Wed Nov 20, 2019 1:22 am
by ESP-Marius
It needs the path of the tiny-test framework, try something like: export TEST_FW_PATH=$IDF_PATH/tools/tiny-test-fw
Re: Python tools fail with "ImportError: No module named IDF"
Posted: Wed Nov 20, 2019 4:00 am
by jhubbardsf
Yup, I ended up figuring that out a little bit ago. I had to fix a few python programs that don't seem to be updated to the current versions (yaml file broke and example_test.py didn't import everything properly). But finally got it working. Thank you.
Was that somewhere in the documentation I missed or would I have to look through the source code to figure that out?
Re: Python tools fail with "ImportError: No module named IDF"
Posted: Wed Nov 20, 2019 4:09 am
by ESP-Marius
That's good.
It's mentioned as a comment in the .py example test files, but I'm not aware of any other documentation that describes how to run these tests.
Re: Python tools fail with "ImportError: No module named IDF"
Posted: Wed Nov 20, 2019 5:12 am
by jhubbardsf
Cool. I'll try to make a note to create pull requests to fix those issues and add it to the appropriate documentation.
Re: Python tools fail with "ImportError: No module named IDF"
Posted: Wed Nov 20, 2019 10:00 pm
by pablolode
Hi, I have the least problem running example_test.py
Code: Select all
pablo @ pablo-notbuk ~ / esp32 / workspace / websocket $ python example_test.py
Traceback (most recent call last):
File "example_test.py", line 4, in <module>
import IDF
ImportError: No module named IDF
I have executed in terminal:
Code: Select all
export TEST_FW_PATH = $ IDF_PATH: / tools / tiny-test-fw
But I can't make it work.
Could you tell me how they solved it?
Thank you
Re: Python tools fail with "ImportError: No module named IDF"
Posted: Fri Nov 22, 2019 4:40 am
by jhubbardsf
Hey, sorry I didn't respond sooner. Don't know how to get email notifications on this forum yet. I made the change on my fork.
https://github.com/YeetBox/esp-idf/blob ... est.py#L22
Edit: Just realized you got a different error. But you'll get that one too after you fix yours. Let me look through my commits and see if it was a code change or an env variable change.
Edit2: I had assumed when you posted a topic you were automatically subscribed to it. You aren't... gotta subscribe. Now I know.
Re: Python tools fail with "ImportError: No module named IDF"
Posted: Fri Nov 22, 2019 4:48 am
by jhubbardsf
pablolode wrote: ↑Wed Nov 20, 2019 10:00 pm
Hi, I have the least problem running example_test.py
Code: Select all
pablo @ pablo-notbuk ~ / esp32 / workspace / websocket $ python example_test.py
Traceback (most recent call last):
File "example_test.py", line 4, in <module>
import IDF
ImportError: No module named IDF
I have executed in terminal:
Code: Select all
export TEST_FW_PATH = $ IDF_PATH: / tools / tiny-test-fw
But I can't make it work.
Could you tell me how they solved it?
Thank you
Ok, looking at your export statement I'm not sure if there was a formatting error or if you really have all those spaces but either way it doesn't look correct. But you'd want to do an
Code: Select all
export TEST_FW_PATH=$IDF_PATH/tools/tiny-test-few
You have a semi colon after IDF_PATH and want a slash. I had to make a few other changes before it'd work, so before you go crazy debugging it check out the last couple commits in my fork.
I put that line in my ~/.profile and since my zsh terminal doesn't source that by default I also added
to my ~/.zshrc. If that's confusing to you don't worry about it and just remember to source the export TEST_FW_PATH that line I pasted above in the terminal.
Re: Python tools fail with "ImportError: No module named IDF"
Posted: Sun Nov 24, 2019 1:31 am
by pablolode
ok
Re: Python tools fail with "ImportError: No module named IDF"
Posted: Thu Aug 13, 2020 6:52 am
by creigelde
You need a file named __init__.py (two underscores on each side) in every folder in the hierarchy. This is what python looks for to know that it should access a particular folder. The files are meant to contain initialization instructions but even if you create them empty this will solve it. To get rid of this error “ImportError: No
module named”, you just need to create __init__.py in the appropriate directory and everything will work fine.