Problems With serial_asyncio

Having trouble getting stuff to work in Python on Raspberry Pi.

I made a new updated Full Raspbian install last night.

I ran the pi dependencies and was getting errors. I came to the conclusion (right or wrong) that it was because 3.5 was being used instead of 3.7. I made that change and pi dependencies ran without errors.

When I tried to run a simple program like set_all_leds.py, I got an error where aiohttp wasn’t found. So I installed it again but this time with pip3 and I got past that issue.

Now I am stuck on No module named ‘serial_asyncio’

I have tried installing with pip3 and I am getting Could not install packages due to an EnvironmentError: 404 Client Error: Not found for url: https://pypi.org/simple/serial-asyncio

Are others getting this error? Did you find a work around? Is there a good way to update the pi dependencies file so others can avoid this same issue?

Thanks :slight_smile:

1 Like

OK I got past this error with pip3 install pyserial-asyncio but now I’m on ttyS0 issues. So I’m not sure if this fixed it, but I am past those initial errors.

The Pi is basically Linux so you need to give yourself permission to use the serial ports. In Linux that means being a member of the “dialout”

sudo adduser $USER dialout

But I see in another message you got it to work but I’ll leave this for others.

Something similar may be needed for a Mac or Windows.

1 Like

I ran into this problem and the solution was to choose a consistent version of Python. The newest installed OS uses Python 3.7. I set everything to use Python 3.5 and had no problems. So use 3.5 for installation, dependencies and running programs.

Also, I initially has asyncio issues because I had no connected the Pi correctly to the RVR. /dev/ttyS0 is not created if serial IO is not possible. One of my wires had a short. I replaced my wires and it worked.

@Kinvert - I ran into basically the exact same issues as you did. Thank you very much for posting your progress along the way.

I am running the latest Raspian Buster on a Pi Zero W. After getting Raspian installed and updated/upgraded, I tried following the Sphero guide. As others have mentioned, the default version of Python in Raspian is v2.7, which will cause issues when trying to install the dependecies. I thought I’d jot down the commands I used to set the default to Python v3.7 which is also included by default in Raspian Buster.

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2

afterwards, type the following and you should now have Python 3.7 as your default instead of 2.7.

python --version

At this point I tried to install the Sphero dependecies, which went smoothly. However, I still had errors trying to run the Sphero example Python LED scripts. These were corrected by issuing the following commands (thanks to @Kinvert!)

pip3 install aiohttp
pip3 install pyserial-asyncio

At this point I was finally able to run the Sphero example LED Python scripts without any errors.

Again, thank you @Kinvert for your very helpful posts above.

2 Likes

As a note for future readers, I was seeing this error on a Pi Zero W, and then I remembered I had enabled the serial console in order to set the thing up over an FTDI / USB cable. Disabling the serial port console (via raspi-config -> Interface -> Serial) got me past this.

1 Like

I’ve also run into similar problems trying to get things working. Thanks @Kinvert and everyone else on this thread for posting your solutions. I’m running the latest raspbian Linux raspberrypi 4.19.75+ #1270 Tue Sep 24 18:38:54 BST 2019 armv6l GNU/Linux on a Pi Model B v2.0 (according to pinout).

I have python 3.7 installed and I updated pidependencies.sh to replace python3.5 to python3.7.

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1

After trying to rerun ./pidependencies.sh it didn’t fix my problem, I still received errors about aiohttp library not found. I followed the advice by @ogiewon and used pip3 to install both aiohttp and pyserial-asyncio and that seemed to fix the problem about not finding the aiohttp library.

pip3 install aiohttp
pip3 install pyserial-asyncio

Similar to @Kinvert I then hit the ttyS0 issue but I found his github suggestion here and changed /dev/ttyS0 to /dev/serial0 in the file sphero-sdk-raspberrypi-python/sphero_sdk/observer/serial_observer_port.py.

I did disable the serial port console (via raspi-config -> Interface -> Serial) but I still never had a /dev/ttyS0 device showing up.

1 Like