Compiling error in arduino cause Python ImportError serial (i have pyserial installed)

Hi, Thank you for reading.
I'm trying to compile a simple blink test in VSCode with PlatformIO extension, it is not my first time, literaly, that was work one hour ago with other code, but now, no one of both works, i don't know what i touched that i shouldent was touch... :sweat_smile:
This is the code:

#include <Arduino.h>
/*
  Blink

  Turns an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino
  model, check the Technical Specs of your board at:
  https://www.arduino.cc/en/Main/Products

  modified 8 May 2014
  by Scott Fitzgerald
  modified 2 Sep 2016
  by Arturo Guadalupi
  modified 8 Sep 2016
  by Colby Newman

  This example code is in the public domain.

  https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink
*/

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

And when i compile, i get this error:

Processing uno (platform: atmelavr; board: uno; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------
ImportError: cannot import name 'Serial' from 'serial' (C:\Users\Javier\.platformio\penv\lib\site-packages\serial\__init__.py):  File "C:\Users\Javier\.platformio\penv\lib\site-packages\platformio\builder\main.py", line 101:
    env = DefaultEnvironment(**DEFAULT_ENV_OPTIONS)
  File "C:\Users\Javier\.platformio\packages\tool-scons\scons-local-4.4.0\SCons\Defaults.py", line 83:      
    _default_env = SCons.Environment.Environment(*args, **kw)
  File "C:\Users\Javier\.platformio\packages\tool-scons\scons-local-4.4.0\SCons\Environment.py", line 1030: 
    apply_tools(self, tools, toolpath)
  File "C:\Users\Javier\.platformio\packages\tool-scons\scons-local-4.4.0\SCons\Environment.py", line 116:  
    _ = env.Tool(tool)
  File "C:\Users\Javier\.platformio\packages\tool-scons\scons-local-4.4.0\SCons\Environment.py", line 1905: 
    tool = SCons.Tool.Tool(tool, toolpath, **kwargs)
  File "C:\Users\Javier\.platformio\packages\tool-scons\scons-local-4.4.0\SCons\Tool\__init__.py", line 118:
    module = self._tool_module()
  File "C:\Users\Javier\.platformio\packages\tool-scons\scons-local-4.4.0\SCons\Tool\__init__.py", line 201:
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883:

  File "<frozen importlib._bootstrap>", line 241:

  File "C:\Users\Javier\.platformio\penv\lib\site-packages\platformio\builder\tools\pioupload.py", line 24:
    from serial import Serial, SerialException
================================================= [FAILED] Took 2.74 seconds =================================================

Environment    Status    Duration
-------------  --------  ------------
uno            FAILED    00:00:02.739
============================================ 1 failed, 0 succeeded in 00:00:02.739 ============================================

I don`t have any idea of what happen
For give more information i can say:

  • No works with any board
  • No works with any baudarate
  • No works with any code
  • As i say in title, i have Pyserial installed, pip pdated and python 3.10.7

It looks like you try to compile C++ code with Python compiler (interpretator)

Oh, but why?, i'm clicking the same button that i was clicked every time before, let me add some screenshots:
Platform IO buttons
This are the butons of platform IO on VSCode, circled, are the butons i use to compile and load program on arduino, like the arduino IDE

Python buttons
And this is the button to run Python.

Can be some error on Platform IO program to compile? any .py or something.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.