Python built-in socket package upgrade

439 Views Asked by At

I had python 3.7.1 installed on my raspberry pi. I upgraded to python 3.9.1 using pyenv with these instructions:

https://yeti.co/blog/setting-up-a-raspberry-pi-with-raspbian-and-pyenv-running-python-35/

Now, I run python 3.9.1 as seen per the command python3 -V, but when I run my program I get errors because the built-in socket package does not seem to be upgraded to 3.9.1. I can see this because when I run dir(socket) in python3, I am missing the 3.9.1 socket add-ons (named J1939).

What is the way to upgrade the socket module? Since it is a built-in package, I am not able to upgrade it with pip3.

Thank you.

1

There are 1 best solutions below

0
On

The issue was not with Python. The socket module upgrades with the python upgrade.

The issue was that the kernel module can-j1939 was not enabled by default on the raspberry pi.

I followed the instructions to add a new kernel module here: https://www.raspberrypi.org/documentation/linux/kernel/building.md#default_configuration

I configured the kernel with menuconfig to get can-1939

  • Networking Support - Can bus subsystem support - SAE J1939

I then built the kernel modules.

I activated the can-1939 module.

sudo modprobe can-j1939

Last step was to manually add the header files:

sudo cp ~/linux/include/uapi/linux/can.h /usr/include/linux/can.h
sudo cp ~/linux/include/uapi/linux/can/j1939.h /usr/include/linux/can/

The link below was useful, but it is meant for debian and not the raspberry pi: https://github.com/linux-can/can-utils/blob/master/can-j1939-install-kernel-module.md