May 24, 2018

python 2.7 and pyserial issue - no _port

I'm restricted to python 2.7 for now. Have some serial hardware (a Roboclaw motor controller) to interface to via USB. The manufacturer provided some simple python scripts.

When I run the basic script, it complains that AttributeError: Roboclaw instance has no attribute '_port'.

I've tried sudo apt-get install python-serial. No luck. Still same problem.

I tried sudo apt-get install python3-serial, just to see if compatible with 2.x. No luck.

What I wanted to do was blow away ALL python and re-install just what I need. But I read (?) that raspbian/debian uses python for package management?

Error is:

Traceback (most recent call last): File "roboclaw_simplepwm.py", line
14, in rc.ForwardM1(address,32) #1/4 power forward File
"/home/devchu/dev/roboclaw_python/roboclaw_python/roboclaw.py", line
647, in ForwardM1 return self._write1(address,self.Cmd.M1FORWARD,val)
File "/home/devchu/dev/roboclaw_python/roboclaw_python/roboclaw.py",
line 311, in _write1 self._sendcommand(address,cmd) File
"/home/devchu/dev/roboclaw_python/roboclaw_python/roboclaw.py", line
126, in _sendcommand self._port.write(chr(address)) **AttributeError:
Roboclaw instance has no attribute '_port'**

The Roboclaw device is seen (dmesg). Also I ran their very basic script which just does an open() and that script works.

dpkg --get-selections|grep python
dh-python install
libpython-stdlib:armhf install
libpython2.7-minimal:armhf install
libpython2.7-stdlib:armhf install
libpython3-stdlib:armhf install
libpython3.5:armhf install
libpython3.5-minimal:armhf install
libpython3.5-stdlib:armhf install
python install
python-apt-common install
python-minimal install
python-serial install
python2.7 install
python2.7-minimal install
python3 install
python3-apt install
python3-minimal install
python3-serial install
python3.5 install
python3.5-minimal install

I'm running Raspberry/Raspbian (I believe it's Stretch) from late last year.

Any tips?

Click Here!