Python tools fail with "ImportError: No module named IDF"

jhubbardsf
Posts: 21
Joined: Wed Oct 30, 2019 5:17 am

Python tools fail with "ImportError: No module named IDF"

Postby jhubbardsf » Tue Nov 19, 2019 7:35 pm

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.

ESP-Marius
Posts: 74
Joined: Wed Oct 23, 2019 1:49 am

Re: Python tools fail with "ImportError: No module named IDF"

Postby ESP-Marius » Wed Nov 20, 2019 1:22 am

It needs the path of the tiny-test framework, try something like: export TEST_FW_PATH=$IDF_PATH/tools/tiny-test-fw

jhubbardsf
Posts: 21
Joined: Wed Oct 30, 2019 5:17 am

Re: Python tools fail with "ImportError: No module named IDF"

Postby jhubbardsf » Wed Nov 20, 2019 4:00 am

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?

ESP-Marius
Posts: 74
Joined: Wed Oct 23, 2019 1:49 am

Re: Python tools fail with "ImportError: No module named IDF"

Postby ESP-Marius » Wed Nov 20, 2019 4:09 am

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.

jhubbardsf
Posts: 21
Joined: Wed Oct 30, 2019 5:17 am

Re: Python tools fail with "ImportError: No module named IDF"

Postby jhubbardsf » Wed Nov 20, 2019 5:12 am

Cool. I'll try to make a note to create pull requests to fix those issues and add it to the appropriate documentation.

pablolode
Posts: 2
Joined: Tue Nov 12, 2019 11:14 pm

Re: Python tools fail with "ImportError: No module named IDF"

Postby pablolode » 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

jhubbardsf
Posts: 21
Joined: Wed Oct 30, 2019 5:17 am

Re: Python tools fail with "ImportError: No module named IDF"

Postby jhubbardsf » Fri Nov 22, 2019 4:40 am

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.
Last edited by jhubbardsf on Fri Nov 22, 2019 5:03 am, edited 1 time in total.

jhubbardsf
Posts: 21
Joined: Wed Oct 30, 2019 5:17 am

Re: Python tools fail with "ImportError: No module named IDF"

Postby jhubbardsf » Fri Nov 22, 2019 4:48 am

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

Code: Select all

source ~/.profile
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.

pablolode
Posts: 2
Joined: Tue Nov 12, 2019 11:14 pm

Re: Python tools fail with "ImportError: No module named IDF"

Postby pablolode » Sun Nov 24, 2019 1:31 am

ok

creigelde
Posts: 1
Joined: Thu Aug 13, 2020 6:49 am

Re: Python tools fail with "ImportError: No module named IDF"

Postby creigelde » Thu Aug 13, 2020 6:52 am

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.

Who is online

Users browsing this forum: Google [Bot] and 80 guests