Import serial python ошибка

and I got a question when I run my Python code.

I installed Python 2.7 on Windows 7, bit 64.
I got an error «No module named serial» when I compiled my code:

import serial

ser = serial.Serial("COM5", 9600)

ser.write("Hello world")

x = ser.readline()

print(x)

I tried many ways to crack this problem, such as installed Canopy to setup virtual environment, make sure ‘pip’ is there, no Python v 3.x installed.
But still cannot get it out.

Any advice would be appreciated.

Colonel Thirty Two's user avatar

asked Oct 21, 2015 at 18:54

Amber.G's user avatar

Serial is not included with Python. It is a package that you’ll need to install separately.

Since you have pip installed you can install serial from the command line with:

pip install pyserial

Or, you can use a Windows installer from here. It looks like you’re using Python 3 so click the installer for Python 3.

Then you should be able to import serial as you tried before.

answered Oct 21, 2015 at 19:02

Hosack's user avatar

HosackHosack

1,4971 gold badge8 silver badges10 bronze badges

2

You must pip install pyserial first.

answered Oct 21, 2015 at 19:00

xrisk's user avatar

xriskxrisk

3,79022 silver badges45 bronze badges

First use command

pip uninstall pyserial

Then run again

 pip install pyserial

The above commands will index it with system interpreter.

schoolcoder's user avatar

schoolcoder

1,5363 gold badges14 silver badges31 bronze badges

answered Jun 20, 2019 at 11:17

Vikas's user avatar

VikasVikas

1011 silver badge2 bronze badges

You must have the pyserial library installed. You do not need the serial library.Therefore, if the serial library is pre-installed, uninstall it. Install the pyserial libray. There are many methods of installing:-

  1. pip install pyserial
  2. Download zip from pyserial and save extracted library in Lib>>site-packages folder of Python.
  3. Download wheel and install wheel using command: pip install <wheelname>

Link: https://github.com/pyserial/pyserial/releases

After installing Pyserial, Navigate to the location where pyserial is installed. You will see a «setup.py» file. Open Power Shell or CMD in the same directory and run command «python setup.py install«.
Now you can use all functionalities of pyserial library without any error.

answered Feb 20, 2018 at 4:49

Johnny's user avatar

JohnnyJohnny

1171 silver badge8 bronze badges

2

In my case the command below did the job

pip3 install pyserial

answered Aug 20, 2020 at 8:05

aro's user avatar

aroaro

811 silver badge2 bronze badges

answered Feb 28, 2017 at 8:11

Soumik Debnath's user avatar

sudo apt install python-serial python3-serial

Solved it, using it for esp32

Sven Eberth's user avatar

Sven Eberth

3,04712 gold badges23 silver badges29 bronze badges

answered Aug 21, 2021 at 12:07

user3196006's user avatar

I had this same problem multiple times but finally found solution.

I had multiple Python versions installed. Like in Raspberry Pi there was Python3.5 installed and I installed also 3.9.2 without uninstalling 3.5. Then I installed pyserial with pip and tried my program. No module… But the reason was that the linux symbolic link in python3 pointed to python3.9.2 version but pip3 pointed to python3.5. So pyserial was installed in python3.5 and understandably was not found when run python3.9.2. Then I changed symbolic link in pip3 to right version and voila, everything works fine!

answered Mar 10, 2021 at 11:27

Kim Weiss's user avatar

  1. Firstly uninstall pyserial using the command pip uninstall pyserial
  2. Then go to https://www.lfd.uci.edu/~gohlke/pythonlibs/
  3. download the suitable pyserial version and then go to the
    directory where the file is downloaded and open cmd there
  4. then type pip install «filename»(without quotes)

answered Mar 17, 2018 at 20:07

satinder singh's user avatar

Happened to me. Something was broken. All the solutions presented didn’t work.

sudo pip install serial
Requirement already satisfied: serial in /usr/local/lib/python3.8/dist-packages (0.0.97)

sudo pip3 install serial
Requirement already satisfied: serial in /usr/local/lib/python3.8/dist-packages (0.0.97)

Same for pyserial, it was already installed.

Solution: I replaced the symbolic link /usr/bin/python to use python3 instead of python2.

answered Jul 4, 2022 at 18:22

physnoct's user avatar

Usually what can happen as was in my case is installing a newer version manually can change the placement of the pyserial from minimal to the upgraded version.

For example, I had just installed Python 3.10 before installing Arduino IDE and that just caused a heck of problems.

I uninstalled pyserial by trying pip uninstall and then

I uninstalled python3.10,

sudo apt purge python3.10

Which after a reboot later, I installed pip install pyserial again, and that did the trick.

answered May 19, 2022 at 14:44

NaidarDevil's user avatar

A common error you may encounter when using Python is modulenotfounderror: no module named ‘serial’.

This error occurs when the Python interpreter cannot detect the pySerial library in your current environment.

You can install pySerial in Python 3 with python -m pip install pyserial.

This tutorial goes through the exact steps to troubleshoot this error for the Windows, Mac and Linux operating systems.


Table of contents

  • ModuleNotFoundError: no module named ‘serial’
    • What is ModuleNotFoundError?
    • What is pySerial?
  • Always Use a Virtual Environment to Install Packages
    • How to Install pySerial on Windows Operating System
      • pySerial installation on Windows Using pip
    • How to Install pySerial on Mac Operating System using pip
    • How to Install pySerial on Linux Operating Systems
      • Installing pip for Ubuntu, Debian, and Linux Mint
      • Installing pip for CentOS 8 (and newer), Fedora, and Red Hat
      • Installing pip for CentOS 6 and 7, and older versions of Red Hat
      • Installing pip for Arch Linux and Manjaro
      • Installing pip for OpenSUSE
      • pySerial installation on Linux with Pip
  • Installing pySerial Using Anaconda
    • Check pySerial Version
  • Summary

ModuleNotFoundError: no module named ‘serial’

What is ModuleNotFoundError?

The ModuleNotFoundError occurs when the module you want to use is not present in your Python environment. There are several causes of the modulenotfounderror:

The module’s name is incorrect, in which case you have to check the name of the module you tried to import. Let’s try to import the re module with a double e to see what happens:

import ree
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
1 import ree

ModuleNotFoundError: No module named 'ree'

To solve this error, ensure the module name is correct. Let’s look at the revised code:

import re

print(re.__version__)
2.2.1

You may want to import a local module file, but the module is not in the same directory. Let’s look at an example package with a script and a local module to import. Let’s look at the following steps to perform from your terminal:

mkdir example_package

cd example_package

mkdir folder_1

cd folder_1

vi module.py

Note that we use Vim to create the module.py file in this example. You can use your preferred file editor, such as Emacs or Atom. In module.py, we will import the re module and define a simple function that prints the re version:

import re

def print_re_version():

    print(re.__version__)

Close the module.py, then complete the following commands from your terminal:

cd ../

vi script.py

Inside script.py, we will try to import the module we created.

import module

if __name__ == '__main__':

    mod.print_re_version()

Let’s run python script.py from the terminal to see what happens:

Traceback (most recent call last):
  File "script.py", line 1, in ≺module≻
    import module
ModuleNotFoundError: No module named 'module'

To solve this error, we need to point to the correct path to module.py, which is inside folder_1. Let’s look at the revised code:

import folder_1.module as mod

if __name__ == '__main__':

    mod.print_re_version()

When we run python script.py, we will get the following result:

2.2.1

Lastly, you can encounter the modulenotfounderror when you import a module that is not installed in your Python environment.

What is pySerial?

pySerial is a library that provides support for serial connections over a variety of different devices, including serial ports, Bluetooth dongles, infra-red sorts etc.

The simplest way to install pySerial is to use the package manager for Python called pip. The following installation instructions are for the major Python version 3.

Always Use a Virtual Environment to Install Packages

It is always best to install new libraries within a virtual environment. You should not install anything into your global Python interpreter when you develop locally. You may introduce incompatibilities between packages, or you may break your system if you install an incompatible version of a library that your operating system needs. Using a virtual environment helps compartmentalize your projects and their dependencies. Each project will have its environment with everything the code needs to run. Most ImportErrors and ModuleNotFoundErrors occur due to installing a library for one interpreter and using the library with another interpreter. Using a virtual environment avoids this. In Python, you can use virtual environments and conda environments. We will go through how to install pySerial with both.

How to Install pySerial on Windows Operating System

First, you need to download and install Python on your PC. Ensure you select the install launcher for all users and Add Python to PATH checkboxes. The latter ensures the interpreter is in the execution path. Pip is automatically on Windows for Python versions 2.7.9+ and 3.4+.

You can check your Python version with the following command:

python3 --version

You can install pip on Windows by downloading the installation package, opening the command line and launching the installer. You can install pip via the CMD prompt by running the following command.

python get-pip.py

You may need to run the command prompt as administrator. Check whether the installation has been successful by typing.

pip --version

pySerial installation on Windows Using pip

To install pySerial, first, create the virtual environment. The environment can be any name, in this we choose “env”:

virtualenv env

You can activate the environment by typing the command:

envScriptsactivate

You will see “env” in parenthesis next to the command line prompt. You can install pySerial within the environment by running the following command from the command prompt.

python3 -m pip install pyserial

We use python -m pip to execute pip using the Python interpreter we specify as Python. Doing this helps avoid ImportError when we try to use a package installed with one version of Python interpreter with a different version. You can use the command which python to determine which Python interpreter you are using.

How to Install pySerial on Mac Operating System using pip

Open a terminal by pressing command (⌘) + Space Bar to open the Spotlight search. Type in terminal and press enter. To get pip, first ensure you have installed Python3:

python3 --version
Python 3.8.8

Download pip by running the following curl command:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

The curl command allows you to specify a direct download link. Using the -o option sets the name of the downloaded file.

Install pip by running:

python3 get-pip.py

To install pySerial, first create the virtual environment:

python3 -m venv env

Then activate the environment using:

source env/bin/activate 

You will see “env” in parenthesis next to the command line prompt. You can install pySerial within the environment by running the following command from the command prompt.

python3 -m pip install pyserial

How to Install pySerial on Linux Operating Systems

All major Linux distributions have Python installed by default. However, you will need to install pip. You can install pip from the terminal, but the installation instructions depend on the Linux distribution you are using. You will need root privileges to install pip. Open a terminal and use the commands relevant to your Linux distribution to install pip.

Installing pip for Ubuntu, Debian, and Linux Mint

sudo apt install python-pip3

Installing pip for CentOS 8 (and newer), Fedora, and Red Hat

sudo dnf install python-pip3

Installing pip for CentOS 6 and 7, and older versions of Red Hat

sudo yum install epel-release

sudo yum install python-pip3

Installing pip for Arch Linux and Manjaro

sudo pacman -S python-pip

Installing pip for OpenSUSE

sudo zypper python3-pip

pySerial installation on Linux with Pip

To install pySerial, first create the virtual environment:

python3 -m venv env

Then activate the environment using:

source env/bin/activate 

You will see “env” in parenthesis next to the command line prompt. You can install pySerial within the environment by running the following command from the command prompt.

Once you have activated your virtual environment, you can install pySerial using:

python3 -m pip install pySerial

Installing pySerial Using Anaconda

Anaconda is a distribution of Python and R for scientific computing and data science. You can install Anaconda by going to the installation instructions. Once you have installed Anaconda, you can create a virtual environment and install pySerial.

To create a conda environment, you can use the following command:

conda create -n serial python=3.8

You can specify a different Python 3 version if you like. Ideally, choose the latest version of Python. Next, you will activate the project container. You will see “serial” in parentheses next to the command line prompt.

source activate serial

Now you’re ready to install pySerial using conda.

Once you have activated your conda environment, you can install pySerial using the following command:

conda install -c anaconda pyserial

Check pySerial Version

Once you have successfully installed pySerial, you can check its version. If you used pip to install pySerial, you can use pip show from your terminal.

python3 -m pip show pyserial
Name: pyserial
Version: 3.5
Summary: Python Serial Port Extension

Second, within your python program, you can import the serial and then reference the __version__ attribute:

import serial
print(serial.__version__)
3.5

If you used conda to install pySerial, you could check the version using the following command:

conda list -f pyserial
# Name                    Version                   Build  Channel
pyserial                  3.5                      pypi_0    pypi

Summary

Congratulations on reading to the end of this tutorial. The modulenotfounderror occurs if you misspell the module name, incorrectly point to the module path or do not have the module installed in your Python environment. If you do not have the module installed in your Python environment, you can use pip to install the package. However, you must ensure you have pip installed on your system. You can also install Anaconda on your system and use the conda install command to install pySerial.

Go to the online courses page on Python to learn more about Python for data science and machine learning.

For further reading on missing modules in Python, go to the article:

  • How to Solve Python ModuleNotFoundError: no module named ‘urllib2’.
  • How to Solve ModuleNotFoundError: no module named ‘plotly’.
  • How to Solve Python ModuleNotFoundError: No module named ‘django’.

Have fun and happy researching!

One error that you might encounter when working with Python is:

ModuleNotFoundError: No module named 'serial'

This error occurs when Python can’t find the pyserial package, which contains the serial module in your current Python environment.

This tutorial shows examples that cause this error and how to fix it.

How to reproduce the error

Suppose you want to use the pyserial package to open a serial port.

You import the serial module and write the following code:

import serial

ser = serial.Serial('COM3')

ser.write("Hello world")
x = ser.readline()
print(x)

ser.close()     

But you get the following error when running the code:

Traceback (most recent call last):
  File "main.py", line 1, in <module>
    import serial
ModuleNotFoundError: No module named 'serial'

This error occurs because Python can’t find the pyserial package in the current environment. The pyserial package is not a built-in Python package, so you need to install it before using it.

To see if you have the pyserial package installed, you can run the pip show pyserial command from the terminal as follows:

$ pip3 show pyserial      
WARNING: Package(s) not found: pyserial

If you get the warning shown above, then you need to install the pyserial package.

How to fix this error

To resolve this error, you need to install the pyserial library using pip as shown below:

pip install pyserial

# For pip3:
pip3 install pyserial

Once the module is installed, you should be able to run the code that imports the serial module without receiving the error.

Install commands for other environments

The install command might differ depending on what environment you used to run the Python code.

Here’s a list of common install commands in popular Python environments to install the pyserial package:

# if you don't have pip in your PATH:
python -m pip install pyserial

python3 -m pip install pyserial

# Windows
py -m pip install pyserial

# Anaconda
conda install pyserial

# Jupyter Notebook
!pip install pyserial

Once the module is installed, you should be able to run the code without receiving this error.

Other common causes for this error

If you still see the error even after installing the module, it means that the pyserial package can’t be found in your Python environment.

There are several reasons why this error can happen:

  1. You may have multiple versions of Python installed on your system, and you are using a different version of Python than the one where pyserial is installed.
  2. You might have pyserial installed in a virtual environment, and you are not activating the virtual environment before running your code.
  3. Your IDE uses a different version of Python from the one that has pyserial
  4. The package is not installed in PyCharm

Let’s see how to fix these errors in practice.

1. You have multiple versions of Python

If you have multiple versions of Python installed on your system, you need to make sure that you are using the specific version where the pyserial module is available.

You can test this by running the which -a python or which -a python3 command from the terminal:

$ which -a python3
/opt/homebrew/bin/python3
/usr/bin/python3

In the example above, there are two versions of Python installed on /opt/homebrew/bin/python3 and /usr/bin/python3.

Suppose you run the following steps in your project:

  1. Install pyserial with pip using /usr/bin/ Python version
  2. Install Python using Homebrew, you have Python in /opt/homebrew/
  3. Then you run import serial in your code

The steps above will cause the error because pyserial is installed in /usr/bin/, and your code is probably executed using Python from /opt/homebrew/ path.

To solve this error, you need to run the pip install pyserial command again so that serial is installed and accessible by the active Python version.

2. Python virtual environment is active

Another scenario that could cause this error is you may have pyserial installed in a virtual environment.

Python venv package allows you to create a virtual environment where you can install different versions of packages required by your project.

If you are installing pyserial inside a virtual environment, then the module won’t be accessible outside of that environment.

You can see if a virtual environment is active or not by looking at your prompt in the terminal.

When a virtual environment is active, the name of that environment will be shown inside parentheses as shown below:

In the picture above, the name of the virtual environment (demoenv) appears, indicating that the virtual environment is currently active.

If you run pip install while the virtual environment is active, then the package is installed only for that environment

Likewise, any package installed outside of that virtual environment won’t be accessible from the virtual environment. The solution is to run the pip install command on the environment you want to use.

If you want to install pyserial globally, then turn off the virtual environment by running the deactivate command before running the pip install command.

3. IDE using a different Python version

Finally, the IDE from where you run your Python code may use a different Python version when you have multiple versions installed.

For example, you can check the Python interpreter used in VSCode by opening the command palette (CTRL + Shift + P for Windows and ⌘ + Shift + P for Mac) then run the Python: Select Interpreter command.

You should see all available Python versions listed as follows:

You need to use the same version where you installed pyserial so that the module can be found when you run the code from VSCode.

Once done, you should be able to import pyserial into your code.

4. You see this error in PyCharm

If you’re using PyCharm as your IDE, then this error might occur because the package is not installed in the Python interpreter used by PyCharm.

This is because PyCharm creates a new virtual environment for each project you create using the IDE. When you run the code, an error is shown as follows:

To resolve this error, you can right-click on the squiggly red lines to open the context menu, then click on Show Context Actions > Install package pyserial.

The package should be installed, and you can run the code without receiving any error.

For more information, you can see the guide to install and uninstall packages in PyCharm.

Conclusion

In summary, the ModuleNotFoundError: No module named 'serial' error occurs when the pyserial package is not available in your Python environment. To fix this error, you need to install pyserial using pip.

If you already have the module installed, make sure you are using the correct version of Python, check if the virtual environment is active if you have one, and check for the Python version used by your IDE.

By following these steps, you should be able to import the serial module in your code successfully.

I hope this tutorial is helpful. Happy coding! 👍

I get this traceback when attempting to connect to a serial port on ubuntu 16.04

File "debugRead2.py", line 6, in <module>
ser = serial.Serial('/dev/ttyACM0', 115200)
AttributeError: module 'serial' has no attribute 'Serial'

My file is named debugRead2.py so it isn’t an issue with naming.

When I change:

import serial
ser = serial.Serial('/dev/ttyACM0', 115200)

to

from serial import serial
ser = serial.Serial('/dev/ttyACM0', 115200)

I get:

Traceback (most recent call last):
  File "debugRead2.py", line 1, in <module>
    from serial import serial
ImportError: cannot import name 'serial'

I have both the serial and pyserial packages installed.

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

Closed

samjulien opened this issue

Oct 8, 2016

· 46 comments

Closed

No «Serial» Module

#13

samjulien opened this issue

Oct 8, 2016

· 46 comments

Comments

@samjulien

Hi there. Windows 8.1 here. Followed the instructions on getting set up and receiving the following when trying to upload a blinking light sketch:

Traceback (most recent call last):

  File "C:Program Files (x86)Arduinohardwareespressifesp32/tools/esptool.py", line 25, in <module>

    import serial

ImportError: No module named serial

exit status 1
Error compiling for board ESP32 Dev Module.

Any ideas?

P.S. Thanks for working on this port!

@MrAPierce

Hi I had the same issue, you’re missing pyserial. You can install pyserial via pip. Open CMD as Administrator and type: pip install pyserial

I believe that pip is installed by default when installing python, Pip should go and get pyserial and install it in the correct location. Restart Arduino IDE and Build, worked for me.

rinelb, florianBCD, jsvgoncalves, herrminni, NilsBe, evanlesmez, InRiPa, SudaravanM, pshashipreetham, Qudor-Engineer, and 35 more reacted with thumbs up emoji
crossfireprod, SandUhrGucker, KeithFabre, metal03326, rolim520, and miguepollo reacted with hooray emoji
Qudor-Engineer, the-harry, EpsilonZ, alessandroAmedei, KeithFabre, asxavier, slaveofcode, and miguepollo reacted with heart emoji

@samjulien

Ah, excellent, thanks. Now it compiles and gives me:

esptool.py v2.0-dev
Connecting...

A fatal error occurred: Failed to connect to ESP32: Invalid head of packet ('f')

So that’s something.

@MrAPierce

That error seems related to uploading, double check that you are holding down boot button then pressing the reset button and then releasing both, then click upload (arrow button).

Does it compile by clicking the tick (verify) button?

@samjulien

Yes, it compiles with the verify button, and yes, I’m doing the boot-and-reset press and upload. No dice. If I open the serial monitor at 115200 I do see some boot text and info about the wifi starting, so the device is alive. I’ve got flash frequency at 40MHz and flash speed at 115200, are those right? And does the programmer setting matter? I’ve got AVRISP mkII selected.

@MrAPierce

These are the setting that work for me:

esp32

@samjulien

Sorry for the delayed response — thanks for the screenshot. Still getting the same error for some reason. I’ll keep tinkering.

@MrAPierce

Hi @samjulien, did you have any luck getting this to work?

@sorscode

Hi @samjulien, Did you by chance install the Silabs driver? I was able to get my Dev board working, once I go the driver install on Mac. I just finished testing PubSubClient on the ESP32, and it works good.

@samjulien

@MrAPierce — not yet, still not sure what the problem is. I’m just uploading super simple LED blink code with an LED in pin 12 and a resistor to ground.

@sorscode — are these same drivers by Silabs used for the ESP8266? Googling «silabs esp32» took me to the same page of «CP210x USB to UART Bridge VCP Drivers,» which I do have installed from working with the 8266.

Once I get this working I’m happy to submit a PR to the readme with anything pertinent. Definitely not just trying to be a pain, hoping to help out the larger community by being a guinea pig. :)

@sorscode

@samjulien That would be the one. Which port do you have selected when uploading? I’m going to build a quick Windows 8.1 VM and test.

@samjulien

Okay, cool, thanks. A buddy of mine pointed out that it’s been several months since I installed those drivers for the ESP8266 and perhaps an update to them is in order, so I’ll also give that a go and report back.

@samjulien

Hmm, updated the drivers, took away the LED, did the boot mode dance, changed sketch to just empty setup and void loops — still no dice. Same invalid head of packet error. Settings are as you have it above. Weird.

@AnalogLamb

@tamberg

@samjulien

Yeah, above I had already installed pyserial and was able to compile but got a different error. That was on Windows 8.1. I just got a new laptop with Windows 10 on it and will give this another shot soon.

@yashchitalia

I too am seeing the serial error «ImportError: No module named serial» in spite of having both python and pyserial. When I opened up a python console on my Terminal and imported serial, that worked fine. Any suggestions?
My guess, is that the Arduino compiler isn’t running the right version of Python, it may be using the default version that comes inbuilt with the Mac, but I’m not sure how I could test this theory.

@me-no-dev

Arduino compile runs the version of python that you have in the path :) so basically starting a shell without running .bash_profile and executing python. Where is your python installed? Why not use the default one (I use it daily and it’s totally fine)?

@yashchitalia

No that was just a theory. Turns out, I am running the inbuilt version of python, but the Arduino compiler still returns an error importing «serial». Importing serial in the terminal works fine. In fact, I printed the command that had failed in the compiler (using the verbose output functionality), and ran it in the terminal, and that executed fine.
So I’m not sure what’s going on there.

@me-no-dev

your PATH variable is different if you run in terminal than what programs trying to execute command see. Usually that is limited to /usr/bin:/usr/sbin:usb/local/bin:/usr/local/sbin
run which python in terminal and see where python is. It might be different than python that might be in one of the locations by default

@yashchitalia

So which python returns /usr/local/bin, and that’s why I think its running the inbuilt version of python.

@me-no-dev

ok here is an idea :)
prepend which "{compiler.python.cmd}" && to this command and run build. it should print the path it sees right before building the bin

@me-no-dev

recipe.objcopy.hex.pattern=which "{compiler.python.cmd}" && "{compiler.python.cmd}" "{runtime.platform.path}/tools/esptool.py" --chip esp32 elf2image --flash_mode "{build.flash_mode}" --flash_freq "{build.flash_freq}" -o "{build.path}/{build.project_name}.bin" "{build.path}/{build.project_name}.elf"

@yashchitalia

So that worked! Thanks a lot! Adding the text to platform.txt revealed that the path it was trying to use was at /usr/bin/. However, changing that path in platform.txt seems to throw a genericexit status 1 Error compiling for board ESP32 Dev Module. error. Any suggestions?

@me-no-dev

do not change the path :)
open terminal and do

sudo mv /usr/bin/python /usr/bin/python_other
sudo ln -s /usr/local/bin/python /usr/bin/python

that will link the correct python to /usr/bin and save the day :)

@yashchitalia

So both those commands are forbidden. But I get the general idea. I’ll try some other things out (like creating an alias, etc.), and see if that works.
Thanks a lot!

@evanmj

I had this same issue on windows with the sparkfun board… I installed pyserial, then got the next issue. Then I went back to holding the reset button while it programmed, and it worked. Thanks guys!

@dgdosen

Hi all;

I’m working on a mac with homebrew installed python.

Arduino seems to be ignoring my path — as I choose to use the homebrew python over the system python.

Nevertheless, if I brew unlink python — leaving only the system python, I can:

  • run the system python
  • see that pyserial is not installed
  • install pip (using sudo)
  • install pyserial (using sudo)
  • run the python get.py command
  • compile the sketch.

I don’t have my esp32 hooked up right now, but will test it later.

@dgdosen

FYI — the above solution works (for homebrewed python macs) I was able to upload sketches and get them working on my esp32 (ESP32 Thing from Sparkfun)

Ideally, the IDE would have recognize my path settings so one can avoid the work around.

Now I want to find/use a CLI-based toolchain to just avoid the Arduino IDE.

@me-no-dev

@dgdosen if you want to use it without the IDE:

  • Download and install esp-idf
  • Create blank idf project (from one of the examples)
  • in the project folder, create a folder called components
  • git clone this repository inside components as name arduino (git clone https://github.com/espressif/arduino-esp32.git arduino)
  • make menuconfig has some Arduino options (maybe enable arduino autostart)
  • in your main.cpp, include Arduino.h and format it as any other sketch (if autostart is enabled)
  • make flash monitor will build, upload and open serial monitor

@blackketter

@me-no-dev

@blackketter

Well, I haven’t dug in deeply but a blink example compiled, downloaded and ran perfectly on my SparkFun ESP32 Thing.

@anziclone

So I figured out a workaround for this problem and got the code to work on a Mac.

  1. Install PySerial using «sudo -H pip install pyserial» in you terminal.

  2. Then get the path of python that you are working on in the terminal using «which python» command. This will give you a path name like below:

/Library/Frameworks/Python.framework/Versions/2.7/bin/python

Copy this path.

  1. Open up the platform.txt in the hardware/espressif/esp32 folder.
    Change the value of compiler.python.cmd=python to compiler.python.cmd=/Library/Frameworks/Python.framework/Versions/2.7/bin/python.
    Also change the value of tools.esptool.cmd=python to tools.esptool.cmd=/Library/Frameworks/Python.framework/Versions/2.7/bin/python. This worked just fine for me and code is compiling and uploaded to the esp32 successfully.

@me-no-dev

this is now all resolved because python is no longer required on Windows

@harshithuchil

here am working with esp32 and arduino but when i connect my esp32 its not showing me the port can anyone solve this ????

@tolo69

@harshithuchil, did you already solve the issue?
I face similiar Problem with ESP32DevC under win10. I have installed the CP2102 VCP-Driver. But after connecting the board it is not appearing in device Manager as virtual COM-port.

@T-vK

@psiphi75

For anyone who comes here from a search engine. On Ubuntu 19.04, my version of pip is for Python 3.7, you need to install pip2.

sudo apt install python-pip

Then install pyserial

@JulianNicholls

Thank you @psiphi75. That was exactly the solution on Ubuntu 19.10 as well.

@lviss

Thank you @psiphi75. That was exactly the solution on Debian 10 as well.

@cyzen

@lbernstone

@spragiot

to solve this issue just follow these steps

  1. install and update python
    sudo apt-get install python3 python3-pip python3-setuptools

  2. set default python version
    sudo update-alternatives —install /usr/bin/python python /usr/bin/python3 10

regards

@vipinsinghal1234

Issue: import serial module not found :
sudo apt install python-is-python3

for library clash :
sudo pip3 uninstall serial
sudo pip3 install pyserial

worked for me because in my case this error was due to python supported by IDE

@zume2020

on Linux systems just try this sudo apt install python-is -python3

@fire17

sudo apt install python-serial python3-serial

solved it! :D

Понравилась статья? Поделить с друзьями:

Не пропустите эти материалы по теме:

  • Яндекс еда ошибка привязки карты
  • Import seaborn as sns ошибка
  • Immergas ошибка 10 мигает что делать
  • Immergas eolo star ошибка 01 что делать
  • Immergas eolo mythos ошибка е11

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии