"No module named 'intelhex' compile error" - unable to permanently delete the tool-esptoolpy folder

Complete newbie here…

When trying to Upload from PIO to an ESP32 I get same the error others have had:

ModuleNotFoundError: No module named ‘intelhex’

The solution of deleting C:\Users\<user>\.platformio\packages\tool-esptoolpy does not work for me:

Each time I delete the folder, and click Build or Upload, the folder re-appears and the error re-occurs.

I tried re-installing VSC / PIO and to running a simple flashing LED script, and I always get the same error.

Any advice or tips would be greatly appreciated.

Reinstalling VS Code or the plugins won’t help here as they are just the “GUI”.

  • Close VS Code
  • Delete the folders C:\Users\<user>\.platformio\packages\ and C:\Users\<user>\.platformio\frameworks
  • Start VS Code and open your project
  • Wait until PlatformIO installed the missing files

You also might to use a newer platform version which is available by pioarduino’s platform-espressif32:

platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip

Thanks for the response Sivar. Unfortunately I followed your suggested steps without success (same error appears). Not sure if it is me being thick or PlatformIO having a bug.

The framework folder ‘framework-arduinoespressif32’ (the one I believe you told me to delete) is within the ‘packages’ folder’. I tried deleting both, without success and I also downloaded and saved the pioarduino’s ‘platform-espressif32-main’ folder into the ‘packages’ folder whilst deleting the tool-esptoolpy and framework-arduinoespressif32 folders, but this did not work either.

When re-opening VS Code it did the following, and then “an unexpected error occurred”:

Resolving esp32 dependencies…

Tool Manager: Installing platformio/framework-arduinoespressif32 @ ~3.20017.0

Unpacking 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%

Tool Manager: framework-arduinoespressif32@3.20017.241212+sha.dcc1105b has been installed!

Tool Manager: Installing platformio/tool-esptoolpy @ ~2.40900.0

Unpacking 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%

‘C:\Users\Andy’ is not recognized as an internal or external command,

operable program or batch file.

CalledProcessError: Traceback (most recent call last):

File “C:\Users\Andy Bentham\.platformio\penv\Lib\site-packages\platformio\_main_.py”, line 103, in main

cli()  # pylint: disable=no-value-for-parameter

^^^^^

File “C:\Users\Andy Bentham\.platformio\penv\Lib\site-packages\click\core.py”, line 1157, in _call_

return self.main(\*args, \*\*kwargs)

       ^^^^^^^^^^^^^^^^^^^^^^^^^^

File “C:\Users\Andy Bentham\.platformio\penv\Lib\site-packages\click\core.py”, line 1078, in main

rv = self.invoke(ctx)

     ^^^^^^^^^^^^^^^^

File “C:\Users\Andy Bentham\.platformio\penv\Lib\site-packages\platformio\cli.py”, line 85, in invoke

return super().invoke(ctx)

       ^^^^^^^^^^^^^^^^^^^

File “C:\Users\Andy Bentham\.platformio\penv\Lib\site-packages\click\core.py”, line 1688, in invoke

return \_process_result(sub_ctx.command.invoke(sub_ctx))

                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “C:\Users\Andy Bentham\.platformio\penv\Lib\site-packages\click\core.py”, line 1688, in invoke

return \_process_result(sub_ctx.command.invoke(sub_ctx))

                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “C:\Users\Andy Bentham\.platformio\penv\Lib\site-packages\click\core.py”, line 1434, in invoke

return ctx.invoke(self.callback, \*\*ctx.params)

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “C:\Users\Andy Bentham\.platformio\penv\Lib\site-packages\click\core.py”, line 783, in invoke

return \__callback(\*args, \*\*kwargs)

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “C:\Users\Andy Bentham\.platformio\penv\Lib\site-packages\platformio\project\commands\init.py”, line 106, in project_init_cmd

install_project_dependencies(

File “C:\Users\Andy Bentham\.platformio\penv\Lib\site-packages\platformio\package\commands\install.py”, line 107, in install_project_dependencies

already_up_to_date = not install_project_env_dependencies(env, options)

                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “C:\Users\Andy Bentham\.platformio\penv\Lib\site-packages\platformio\package\commands\install.py”, line 132, in install_project_env_dependencies

\_install_project_env_platform(project_env, options),

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “C:\Users\Andy Bentham\.platformio\penv\Lib\site-packages\platformio\package\commands\install.py”, line 149, in _install_project_env_platform

PlatformPackageManager().install(

File “C:\Users\Andy Bentham\.platformio\penv\Lib\site-packages\platformio\package\manager\platform.py”, line 62, in install

p.install_required_packages(force=force)

File “C:\Users\Andy Bentham\.platformio\penv\Lib\site-packages\platformio\platform\_packages.py”, line 76, in install_required_packages

self.install_package(name, force=force)

File “C:\Users\Andy Bentham\.platformio\penv\Lib\site-packages\platformio\platform\_packages.py”, line 70, in install_package

return self.pm.install(spec or self.get_package_spec(name), force=force)

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “C:\Users\Andy Bentham\.platformio\penv\Lib\site-packages\platformio\package\manager\_install.py”, line 47, in install

pkg = self.\_install(spec, skip_dependencies=skip_dependencies, force=force)

      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “C:\Users\Andy Bentham\.platformio\penv\Lib\site-packages\platformio\package\manager\_install.py”, line 116, in _install

self.call_pkg_script(pkg, "postinstall")

File “C:\Users\Andy Bentham\.platformio\penv\Lib\site-packages\platformio\package\manager\base.py”, line 339, in call_pkg_script

subprocess.run(

File “C:\Users\Andy Bentham\.platformio\python3\Lib\subprocess.py”, line 571, in run

raise CalledProcessError(retcode, process.args,

subprocess.CalledProcessError: Command ‘C:\Users\Andy Bentham\.platformio\penv\Scripts\python.exe package-postinstall.py’ returned non-zero exit status 1.

Does that show the problem?

Apologies for my lack of basic understanding…

This isn’t “basic” stuff. This is the “most advanced stuff” :wink:

If this doesn’t help, try reinstalling platformio completely by deleting the whole .platformio folder.

Thanks Sivar, this solution worked. I had to get someone to explain how to input those commands, and there was an issue with the space in my Users account name, but using quotation marks fixed that.

1 Like

Oh yeah…space in username is a “bad thing” :wink:

In this case another option is to change PlatformIO’s core directory to different location (path without a space) by setting the (Windows) environment variable PLATFORMIO_CORE_DIR before (re)installing PlatformIO