[SOLVED] Upload failed, PIO is using own python esptool.py but serial is missing ... hot to fix it correctly?

hi,

installed PlatformIO IDE new and tried to upload my 1st project.
But got the following error:

Uploading .pio/build/XXXXXXXXX
Traceback (most recent call last):
esptool.py v3.0
  File "/Users/chako/.platformio/penv/lib/python3.9/site-packages/serial/serialposix.py", line 322, in open
Serial port tty.usbserial-1120
    self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
FileNotFoundError: [Errno 2] No such file or directory: 'tty.usbserial-1120'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/chako/.platformio/packages/tool-esptoolpy/esptool.py", line 3969, in <module>
    _main()
  File "/Users/chako/.platformio/packages/tool-esptoolpy/esptool.py", line 3962, in _main
    main()
  File "/Users/chako/.platformio/packages/tool-esptoolpy/esptool.py", line 3551, in main
    esp = chip_class(each_port, initial_baud, args.trace)
  File "/Users/chako/.platformio/packages/tool-esptoolpy/esptool.py", line 271, in __init__
    self._port = serial.serial_for_url(port)
  File "/Users/chako/.platformio/penv/lib/python3.9/site-packages/serial/__init__.py", line 90, in serial_for_url
    instance.open()
  File "/Users/chako/.platformio/penv/lib/python3.9/site-packages/serial/serialposix.py", line 325, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port tty.usbserial-1120: [Errno 2] No such file or directory: 'tty.usbserial-1120'
  • Means to me PlatformIO IDE is using its own Python installation instead of my own one.
  • When I try to run the esptool.py of PlatformIO’s toolchain it complains about missing serial module… Which I already installed in my own python installation.

My question(s):

  • What’s the correct way to tell PlatformIO IDE to use my private Python installation instead of its own one?

  • Or alternatively: How can I install the serial module correctly in the PlatformIO IDE toolchain?

thanks in advance for any answer!

bye
Chako

You have selected a wrong upload device. This is not an error in esptoolpy. It is not missing any serial modules as you claim. The error message is about pyserial not being able to open the device file. The device name should be something like /dev/tty.usbserial-1120, not tty.usbserial-1120.

Correct, it’s own pyenv.

It is intended that it uses its isolated pyenv to not interfere with anything else. You may still install it as normal with your pip3 manager, but make sure you delete the old core (remove ~/.platformio, FAQ)

hi Max,

you are absolutely right… thanks for pointing that out.,
Must have been blind when I decided to start this as a topic…

and thanks for the link regarding the environments.

bye
Chako