Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: No module named serial.tools.list_ports (ESPTOOL-249) #350

Closed
eliyastein opened this issue Aug 24, 2018 · 16 comments
Closed

ImportError: No module named serial.tools.list_ports (ESPTOOL-249) #350

eliyastein opened this issue Aug 24, 2018 · 16 comments

Comments

@eliyastein
Copy link

Any help would be much appreciated:

  • Operating system:
$ uname -a
Darwin Chinaski.local 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64
  • Python version: Python 2.7.10

  • ESP hardware in use: ESP8266

$ ./esptool.py --port /dev/tty.SLAB_USBtoUART --baud 115200 write_flash --flash_freq 80m --flash_mode qio --flash_size 4m 0x0000 esp8266espruino/boot_v1.6.bin 0x1000 esp8266espruino/espruino_esp8266_user1.bin 0x3FC000 esp8266espruino/esp_init_data_default.bin 0x3FE000 esp8266espruino/blank.bin
Traceback (most recent call last):
  File "./esptool.py", line 35, in <module>
    import serial.tools.list_ports as list_ports
ImportError: No module named serial.tools.list_ports
@nixmeer
Copy link

nixmeer commented Sep 3, 2018

I got the same issue. I am running on macOS 10.13.6. Esptool installed with the esp32 core and works fine when flashing the esp32 through Arduino IDE. When trying to flash tasmota firmware to an esp8266, I get the same error.

Python 2.7 and 3.7 installed.

@projectgus
Copy link
Contributor

Hi @nixmeer @eliyastein ,

Thanks for being patient while someone got back to you.

I think in both cases the version of pyserial which is installed is too old, and doesn't have serial.tools.list_ports module.

You should be able to fix this by running pip install pyserial, or re-installing esptool with pip install esptool.

I'll add a version check in the top of esptool.py, so the error is clearer.

@jssilva25
Copy link

jssilva25 commented Sep 25, 2018

Hello,

I'm getting the exact same error as the OP, same OS and py27.

I already did pip install pyserial and pip install esptool and I don't think they are outdated:

$ pip show pyserial
Name: pyserial
Version: 3.4
Summary: Python Serial Port Extension
Home-page: https://github.com/pyserial/pyserial
Author: Chris Liechti
Author-email: cliechti@gmx.net
License: BSD
Location: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Requires: 
Required-by: esptool

$ pip show esptool
Name: esptool
Version: 2.5.1.dev0
Summary: A serial utility to communicate & flash code to Espressif ESP8266 & ESP32 chips.
Home-page: https://github.com/espressif/esptool
Author: Fredrik Ahlberg (themadinventor) & Angus Gratton (projectgus)
Author-email: angus@espressif.com
License: GPLv2+
Location: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/esptool-2.5.1.dev0-py2.7.egg
Requires: pyserial, pyaes, ecdsa
Required-by: 

EDIT: It works on the command line:

$ python -m serial.tools.list_ports
/dev/cu.Bluetooth-Incoming-Port
/dev/cu.usbserial-A9M9DV3R
2 ports found

EDIT2: Never mind, I had installed esptool by git clone. Solved it by:

# pip uninstall esptool
# pip uninstall pyserial
# pip uninstall serial # didn't find something to uninstall
# pip install esptool

And now I have to call esptool using full path, otherwise esp-open-sdk gets in the way:
$ /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/esptool.py

Could you please help?
TIA
jss

@vinayprydotinfotech
Copy link

Same error

Traceback (most recent call last):
File "../tools/esptool.py", line 26, in
import serial
ImportError: No module named serial
../Makefile:202: recipe for target '.output/eagle/debug/bin/eagle.app.v6.bin' failed
make[1]: *** [.output/eagle/debug/bin/eagle.app.v6.bin] Error 1
make[1]: Leaving directory '/home/rydot/Downloads/nodemcu-firmware-2.2.1-master_20181207/app'
Makefile:292: recipe for target '.subdirs' failed
make: *** [.subdirs] Error 2


platform pyhton 3.6 ,Ubuntu 16.04 LTS, 64bit
installed
--pip3 install pyserial --user
--pip3 install serial --user
--pip3 install esptool --user
still not working
Any more advice ?

@projectgus
Copy link
Contributor

Hi @vinayprydotinfotech,

(For the record: NodeMCU ships quite an old version of esptool (v1.2-dev) plus some custom modifications.)

If you run /usr/bin/env python (which is the Python interpreter used by the esptool.py script in NodeMCU), is it version 3.6? (Use control-d to exit.)

As it's ubuntu, installing the native PySerial with sudo apt-get install python3-serial may help.

@vinayprydotinfotech
Copy link

vinayprydotinfotech commented Mar 11, 2019 via email

@projectgus
Copy link
Contributor

Anaconda 4.3.

You seem to have Python installed via "Anaconda" in addition to (or instead of) the system Python. This is why 'pip' and system Python packages aren't working. You can try something like this to install pyserial under the "conda" package manager for Anaconda:
https://pyserial.readthedocs.io/en/latest/pyserial.html#from-conda

@mahdieh-dev
Copy link

I used
pip install pyserial
and this issue solved.

@mangelozzi
Copy link

What solved it for me is not calling the script I was testing it with "serial.py", rename to something else.

@NEEHITGOYAL
Copy link

I used
pip install pyserial
and this issue solved.

working fine thanks

@khataei
Copy link

khataei commented Jul 25, 2020

I had the same problem. installing the pyserial didn't work. Then I realized that I don't have pip for Python2.7 and pyserial was installed on Python3.8.
So make sure you have pip for Python2.7 by running
pip --version
And then go for
pip install pyserial

@henkiejan1
Copy link

After upgrade yesterday is esptool not working anymore. I thought that python-pip is not available anymore. Only python3-pip alias pip3

My system:
Linux Inspiron-5370 5.8.12-050812-generic #202009261732 SMP Sat Sep 26 17:35:23 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux Linux Mint 20 with one of the latest kernels

Python3 version:
Python 3.8.5

When i try to install python-pip:
Pakketlijsten worden ingelezen... Klaar Boom van vereisten wordt opgebouwd De statusinformatie wordt gelezen... Klaar E: Kan pakket python-pip niet vinden
Dutch but the translation is: can´t find python-pip package

But after a short research you can get pip for python2 on this site of Python. https://pip.pypa.io/en/stable/installing/ after that you can install esptool and pyserial as berfore.

But there is a warning that python2 stops at januari 2021. So maybe a good idea that esptool runs on python3?

@projectgus
Copy link
Contributor

projectgus commented Oct 8, 2020

But there is a warning that python2 stops at januari 2021. So maybe a good idea that esptool runs on python3?

@henkiejan1 esptool.py supports Python 3 since esptool release 1.3 (January 2017).

In most Debian/Ubuntu based Linux distros (I think including Mint), the pip binary is still the Python 2 Pip but you should be able to do pip3 install esptool. There is also a Debian/Ubuntu package python3-serial that can be installed first (apt install python3-serial) if you'd rather have the Distro's version of pyserial than the Pip version.

@danteruizv8
Copy link

From:

ESP8266_RTOS_SDK/components/esptool_py/esptool/esptool.py
""
esptool.py depends on pyserial, but there is a conflict with a currently installed package named 'serial'.

You may be able to work around this by 'pip uninstall serial; pip install pyserial'
but this may break other installed Python software that depends on 'serial'.

There is no good fix for this right now, apart from configuring virtualenvs.
See #269 (comment) for discussion of the underlying issue(s).""

@github-actions github-actions bot changed the title ImportError: No module named serial.tools.list_ports ImportError: No module named serial.tools.list_ports (ESPTOOL-249) Jun 7, 2021
@JeongJun-Lee
Copy link

If you are working on the VS, you can look into the version of Python environment you're using like below:
image

@neddan
Copy link

neddan commented May 20, 2024

Hi @vinayprydotinfotech,

(For the record: NodeMCU ships quite an old version of esptool (v1.2-dev) plus some custom modifications.)

If you run /usr/bin/env python (which is the Python interpreter used by the esptool.py script in NodeMCU), is it version 3.6? (Use control-d to exit.)

As it's ubuntu, installing the native PySerial with sudo apt-get install python3-serial may help.

I was getting the same error on ubuntu 24.04, pip3 install pyserial did not help and serial was not not installed either when i tried to uninstall both. Eventually @projectgus comment of installing pyserial via apt did the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests