Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9190605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:30:04+00:00 2026-06-17T20:30:04+00:00

I am using the pySerial library to have a Python script log data from

  • 0

I am using the pySerial library to have a Python script log data from an Arduino. I am trying to handle the SerialException when the script cannot connect to the port you provided, and Eclipse says “Undefined variable: SerialException”. Is there something I forgot to import?

Code:

try:
    ser = serial.Serial(port, 9600)
    connected = 1
except SerialException:
    print "No connection to the device could be established"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:30:05+00:00Added an answer on June 17, 2026 at 8:30 pm

    You probably want:

    except serial.SerialException:
       ...
    

    in python, Exceptions are classes derived from Exception. So, when a module/package defines it’s own custom exceptions, they usually get imported in the module/packages’s namespace just like the other classes/functions. This said, putting a:

    from serial import SerialException
    

    at the top of your file would probably also do the trick.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to connect to my phone from my Windows 7 PC using PySerial
I am using python's pySerial library to communicate to a machine (lunar photometer if
I'm using a script importing PySerial to read from COM4 messages I would like
Python version: 2.6.6 PySerial version: 2.5 Arduino board: Duemilanove 328 I have written some
I am currently trying to capture serial data within a python script. I intend
I am using python 2.7.2 with pyserial 2.6. What is the best way to
I am trying to get a python script to write to a serial port
How do I access the USB port using pyserial? I have seen an example
I am trying to slap together a Python data logger and am looking for
I write to my device in hexadecimal format using pyserial : ser.write(\x01\x03\x00\x00\x00\x0A\xC5\xCD) data =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.