Raspbian python 3.9.2 installed, but odrivetool tries to run python 3.7


I am running the odrivetool on a Raspberry Pi (Raspbian), and i just updated the python from 3.7 to 3.9.2 using a bash script i found awhile ago (see code below).

echo -e "Updating python to version 3.9.2"
wget -O /tmp/Python-$version.tar.xz https://www.python.org/ftp/python/$version/Python-$version.tar.xz
cd /tmp
tar xf Python-$version.tar.xz
cd Python-$version
./configure --enable-optimizations
sudo make altinstall
sudo apt -y autoremove
sudo rm -rf /tmp/Python-$version
rm /tmp/Python-$version.tar.xz
sudo ln -s /usr/local/bin/python3.9 /usr/bin/python3.9
echo "alias python=/usr/local/bin/python3.9" >> ~/.bashrc
echo "alias python3=/usr/local/bin/python3.9" >> ~/.bashrc
source ~/.bashrc
cd ..
. ~/.bashrc

The issue is that when i run the odrivetool, and then i try to use the start_liveplotter(lambda: [], there is a serie of errors happening. I noticed that they all point to the usr/local/lib/python3.7. But when i check the python version on my Raspberry Pi python -V, it is 3.9.2. I also made sure to install all libraries (such as matplotlib, numpy, etc.).

Does anyone knows why this error is caused?

start_liveplotter(lambda: [odrv0.axis0.motor.current_control.Iq_measured])
RuntimeError                              Traceback (most recent call last)
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
ImportError                               Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/fibre/shell.py in <module>
----> 1 start_liveplotter(lambda: [odrv0.axis0.motor.current_control.Iq_measured])

/usr/local/lib/python3.7/dist-packages/odrive/utils.py in start_liveplotter(get_var_callback)
     72     """
---> 74     import matplotlib.pyplot as plt
     76     cancellation_token = Event()

/usr/local/lib/python3.7/dist-packages/matplotlib/__init__.py in <module>
    105 # cbook must import matplotlib only within function
    106 # definitions, so it is safe to import from it here.
--> 107 from . import _api, cbook, docstring, rcsetup
    108 from matplotlib.cbook import MatplotlibDeprecationWarning, sanitize_sequence
    109 from matplotlib.cbook import mplDeprecation  # deprecated

/usr/local/lib/python3.7/dist-packages/matplotlib/rcsetup.py in <module>
     24 from matplotlib import _api, animation, cbook
     25 from matplotlib.cbook import ls_mapper
---> 26 from matplotlib.colors import Colormap, is_color_like
     27 from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
     28 from matplotlib._enums import JoinStyle, CapStyle

/usr/local/lib/python3.7/dist-packages/matplotlib/colors.py in <module>
     80 import matplotlib as mpl
     81 import numpy as np
---> 82 from matplotlib import _api, cbook, scale
     83 from ._color_data import BASE_COLORS, TABLEAU_COLORS, CSS4_COLORS, XKCD_COLORS

/usr/local/lib/python3.7/dist-packages/matplotlib/scale.py in <module>
     16 import matplotlib as mpl
     17 from matplotlib import _api, docstring
---> 18 from matplotlib.ticker import (
     19     NullFormatter, ScalarFormatter, LogFormatterSciNotation, LogitFormatter,
     20     NullLocator, LogLocator, AutoLocator, AutoMinorLocator,

/usr/local/lib/python3.7/dist-packages/matplotlib/ticker.py in <module>
    177 import matplotlib as mpl
    178 from matplotlib import _api, cbook
--> 179 from matplotlib import transforms as mtransforms
    181 _log = logging.getLogger(__name__)

/usr/local/lib/python3.7/dist-packages/matplotlib/transforms.py in <module>
     45 from matplotlib import _api
---> 46 from matplotlib._path import (
     47     affine_transform, count_bboxes_overlapping_bbox, update_path_extents)
     48 from .path import Path

ImportError: numpy.core.multiarray failed to import

I found this link that also shows how to install different versions of python on the Raspberry Pi. When i use the command ls /usr/bin/python*, i get all these files :

/usr/bin/python     /usr/bin/python2.7-config  /usr/bin/python3           /usr/bin/python3.7m         /usr/bin/python3-config   /usr/bin/python-config
/usr/bin/python2    /usr/bin/python2-config    /usr/bin/python3.7         /usr/bin/python3.7m-config  /usr/bin/python3m
/usr/bin/python2.7  /usr/bin/python2-pbr       /usr/bin/python3.7-config  /usr/bin/python3.9          /usr/bin/python3m-config

It seems like there are a lot of python files installed and i don’t understand why it tries to run the python version 3.7 instead of the latest one 3.9.2 that i installed.

1 Like