PlatformIO Community

Installation problem (include search path)

Ubuntu Focal, VSCode

My installation suddenly stopped finding .h files.

I have reinstalled everything, created new project:

#include <Arduino.h>

void setup() {
  // put your setup code here, to run once:

void loop() {
  // put your main code here, to run repeatedly:

And what I’m getting is
[real path to my project]/src/main.cpp:1:10: fatal error: ‘Arduino.h’ file not found
#include <Arduino.h>

  • Does the project build?
  • Have you installed any other extension in VSCode, e.g. the Arduino one?
  • The project doesn’t build.
  • There are some other extension, all of them are syntax support, but not Arduino.

Then the file must be truly missing. Delete the content of the /home/<user>/.platformio/packages folder completely and rebuild the project.

I even deleted ~/.platformio/, then it reinstalled itself, with all the same errors.

I’m assuming you’re using the AVR-Arduino framework here, if not correct me.

Is there a folder ~/.platformio/packages/framework-arduino-avr? Does it contain the cores/arduino/Arduino.h file? Is the path to the core folder present in the .vscode/c_cpp_properities.json?

Have you install VSCode in a caged environment like a Flatpak or snap instead of the .deb version?

There is no such folder, nor .json file is present. This is what I have:

 ~  130 ❯ ls -l .platformio/packages/
total 32
drwx------  4 ike ike 4096 jūn 22 20:36 contrib-piohome
drwx------ 51 ike ike 4096 jūn 22 20:36 contrib-pysite
drwx------  8 ike ike 4096 jūn 22 20:37 framework-arduinoespressif8266
drwx------  8 ike ike 4096 jūn 22 20:37 toolchain-xtensa
drwx------  2 ike ike 4096 jūn 22 20:37 tool-esptool
drwx------  6 ike ike 4096 jūn 22 20:37 tool-esptoolpy
drwx------  4 ike ike 4096 jūn 22 20:37 tool-scons
drwx------  2 ike ike 4096 jūn 22 20:37 tool-unity

Ah, then you work with Arduino-ESP8266.

Sorry that is supposed to be in the hidden folder in the root of your project, not in ~/.platformio. Is ~/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/Arduino.h present?

It is, indeed:

 ~ ❯ head ~/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/Arduino.h
 Arduino.h - Main include file for the Arduino SDK
 Copyright (c) 2005-2013 Arduino Team.  All right reserved.

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful,

Good, so that’s there.

Is the path to folder in which Arduino.h resides in the file

Also, can you post the output of the “Verbose Build” task in VSCode (or pio run -v).

.vscode file doesn’t mention this path, although there are many others.

 ~/Documents/PlatformIO/Projects/espk ❯ pio run -v
Traceback (most recent call last):
  File "/usr/local/bin/pio", line 5, in <module>
    from platformio.__main__ import main
  File "/usr/local/lib/python2.7/dist-packages/platformio/", line 21, in <module>
    from platformio import __version__, exception, maintenance, util
  File "/usr/local/lib/python2.7/dist-packages/platformio/", line 22, in <module>
    from platformio import __version__, app, exception, fs, telemetry, util
  File "/usr/local/lib/python2.7/dist-packages/platformio/", line 23, in <module>
    import requests
  File "/usr/local/lib/python2.7/dist-packages/requests/", line 44, in <module>
    import chardet
ImportError: No module named chardet

Can you Rebuild the IntelliSense and post the content of the .vscode/c_cpp_properties.json (pastebin if necessary)?

  1. Have you installed PlatformIO twice? Once in the normal shell via some pip2 install platformio command and once when you installed the VSCode plugin? Two core are bad.
  2. It’s best to execute the PlatformIO command in the PIO Terminal to get the same output as what would happen if VSCode executed it itself
  3. It is especially bad that it says /usr/local/lib/python2.7/dist-packages/platformio/. PlatformIO should target Python3, Python2 was deprecated. If you have two cores then Use the built-in core of the system that you may have installed via pip. Though I definitely recommend to do a pip uninstall platformio and a pip3 install platformio. You should also match the python3 version as the default interpreter in VSCode.


While I am on other tasks, you were right about python2's core, and I uninstalled it.

pip3 install platformio gives me

ERROR: esphome 1.14.3 has requirement platformio==4.0.3, but you'll have platformio 4.3.4 which is incompatible.

I understand that this is where second core came from, namely, esphome.