Can't import pyserial or serial in python 3.4 2017-03 Debian

617 views
Skip to first unread message

zli...@gmail.com

unread,
Jun 28, 2017, 9:33:13 AM6/28/17
to BeagleBoard
I tried to import serial or pyserial in python 3.4 to no avail:

debian@beaglebone:~$ python3
Python 3.4.2 (default, Oct  8 2014, 14:38:51)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import serial
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'serial'
>>> import pyserial
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'pyserial'

If I use python 2.7, then I can import serial but not pyserial:

debian@beaglebone:~$ python
Python 2.7.9 (default, Aug 13 2016, 17:56:53)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyserial
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pyserial
>>> import serial
>>> ser = serial.Serial()

If I list modules with pip, I see pyserial:

debian@beaglebone:~$ pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
Adafruit-BBIO (1.0.3)
astroid (1.2.1)
blinker (1.3)
cffi (0.8.6)
chardet (2.3.0)
colorama (0.3.2)
cryptography (0.6.1)
dropbox (8.0.0)
Flask (0.10.1)
html5lib (0.999)
itsdangerous (0.24)
iw-parse (0.0.2)
Jinja2 (2.7.3)
logilab-common (0.62.0)
MarkupSafe (0.23)
ndg-httpsclient (0.3.2)
pip (9.0.1)
ply (3.4)
pyasn1 (0.1.7)
PyBBIO (0.10)
pycparser (2.10)
pygobject (3.14.0)
pyinotify (0.9.4)
pylint (1.3.1)
pyOpenSSL (0.14)
pyserial (3.3)
requests (2.13.0)
serbus (1.0.5)
setuptools (5.5.1)
six (1.8.0)
urllib3 (1.9.1)
Werkzeug (0.9.6)
wheel (0.24.0)


If I try to upgrade pyserial, I get error saying that I've already got the latest:

debian@beaglebone:~$ sudo pip install --upgrade pyserial
[sudo] password for debian:
Requirement already up-to-date: pyserial in /usr/local/lib/python2.7/dist-packages

Again, my goal is to user serial port on BBB preferably on Python 3.4 instead of 2.7. Right now, importing doesn't work for serial and pyserial in 3.4. Thanks

Dennis Lee Bieber

unread,
Jun 28, 2017, 10:41:59 AM6/28/17
to beagl...@googlegroups.com
On Tue, 27 Jun 2017 22:36:47 -0700 (PDT),
zli...@gmail.com declaimed the following:


>
>If I try to upgrade pyserial, I get error saying that I've already got the
>latest:
>
>
>
>
>*debian@beaglebone:~$ sudo pip install --upgrade pyserial[sudo] password
>for debian: Requirement already up-to-date: pyserial in
>/usr/local/lib/python2.7/dist-packages*
>Again, my goal is to user serial port on BBB preferably on Python 3.4
>instead of 2.7. Right now, importing doesn't work for serial and pyserial
>in 3.4. Thanks

Your default for pip is python2.7; you need to force it to run using
python3.4 in order to have it install the module in the 3.4 library.

Unfortunately, I've not used pip enough to know how to do that; maybe
search for a 3.4 specific pip executable ("which pip" and then change any
2.7 in the path to 3.4)?
--
Wulfraed Dennis Lee Bieber AF6VN
wlf...@ix.netcom.com HTTP://wlfraed.home.netcom.com/

Brett Hamilton

unread,
Jun 29, 2017, 10:56:06 AM6/29/17
to BeagleBoard, zli...@gmail.com
The python module in pyserial is called serial, so no mystery there.

To run a version of pip for your python3.4 you can use "python3 -m pip [pip args]".

zli...@gmail.com

unread,
Jun 29, 2017, 8:08:19 PM6/29/17
to BeagleBoard, zli...@gmail.com
Thanks but this command produces an error:

debian@beaglebone:~$ python3 -m pip list
/usr/bin/python3: No module named pip

How do I install a pip3 or pip for python3? I tried a few combinations with apt-get and couldn't find what to install. I thought that BBB is probably not optimized to run python3 code otherwise these facilities should have been in place for the average python person.

Best,

Dr. John Liu

unread,
Jun 30, 2017, 7:47:26 AM6/30/17
to BeagleBoard

I think I figured this out. I needed to install pip3 aka python3-pip using apt-get. I’ve never done that my whole time using python on any OS. It took me a while to get the combination of python, pip, a dash, and 3 in the right order to get it to install. What’s the preferred programming language on BBB platform?

Graham

unread,
Jun 30, 2017, 10:06:32 AM6/30/17
to BeagleBoard, zli...@gmail.com


On Friday, June 30, 2017 at 6:47:26 AM UTC-5, Dr. John Liu wrote:

What’s the preferred programming language on BBB platform?

----

Well, that sort of depends on what you are trying to do.

--- Graham

==
Reply all
Reply to author
Forward
0 new messages