getting a pyserial not loaded error

Posted by skinnyTOD on Super User See other posts from Super User or by skinnyTOD
Published on 2012-11-06T03:17:34Z Indexed on 2012/11/06 5:06 UTC
Read the original article Hit count: 821

Filed under:
|

I'm getting a "pyserial not loaded" error with the python script fragment below (running OSX 10.7.4). I'm trying to run a python app called Myro for controlling the Parallax Scribbler2 robot - figured it would be a fun way to learn a bit of Python - but I'm not getting out of the gate here.

I've searched out all the Myro help docs but like a lot in-progress open source programs, they are a moving target and conflicting, out of date, or not very specific about OSX.

I have MacPorts installed and installed py27-serial without error. MacPorts lists the python versions I have installed, along with the active version:

Available versions for python:
    none
    python24
    python25
    python25-apple
    python26
    python26-apple
    python27
    python27-apple (active)
    python32

Perhaps stuff is getting installed in the wrong places or my PATH is wrong (I don't much know what I am doing in Terminal and have probably screwed something up).

Trying to find out about my sys.path - here's what I get:

import sys sys.path ['', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages']

Is that a mess? Can I fix it?

Anyway, thanks for reading this far. Here's the python bit that is throwing the error. The error occurs on 'try import serial'.

# Global variable robot, to set SerialPort()
robot = None
pythonVer = "?"
rbString = None
ptString = None
statusText = None

# Now, let's import things
import urllib
import tempfile
import os, sys, time
try:
    import serial
except:
    print("WARNING: pyserial not loaded: can't upgrade!")
    sys.exit()
try:
    input = raw_input # Python 2.x
except:
    pass # Python 3 and better, input is defined

try:
    from tkinter import *
    pythonver = "3"
except:
    try:
        from Tkinter import *
        pythonver = "2"
    except:
        pythonver = "?"

© Super User or respective owner

Related posts about osx

Related posts about python