Upgrade to 18.6.0 with Python 3.8 issues

I upgraded mycodo to version 18.6.0 today, and it seemed to break my system. I then read the changelog (that’s my bad :man_facepalming:)-- and realized I am still running Raspbian Buster and needed to upgrade Python. I installed Python 3.8, then ran:

sudo /opt/Mycodo/mycodo/scripts/upgrade_post.sh

To re-do the upgrade. It looks like I am still having a python or pip version issue? Here’s the upgrade log.

Appreciate any and all help-- I’m an amateur and these Python versions are confusing me…

1 Like

Try deleting your current virtualenv and rebuilding it.

sudo rm -rf /opt/Mycodo/env &&
sudo /opt/Mycodo/mycodo/scripts/upgrade_commands.sh setup-virtualenv-full &&
sudo /opt/Mycodo/mycodo/scripts/upgrade_post.sh &&
sudo service mycodo restart &&
sudo service mycodoflask restart

Narrowing down on the issue; here’s the error I received setting up the virtualenv:


#### Checking Python 3 virtual environment
#### Creating virtual environment at /opt/Mycodo/env
Error: Command '['/opt/Mycodo/env/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 2.

#### Updating pip

#### Checking Python 3 virtual environment
/opt/Mycodo/env/bin/python: No module named pip

#### Installing pip requirements

#### Checking Python 3 virtual environment
/opt/Mycodo/env/bin/python: No module named pip
/opt/Mycodo/env/bin/python: No module named pip

#### Checking for updates to dependencies
Traceback (most recent call last):
  File "/opt/Mycodo/mycodo/utils/update_dependencies.py", line 10, in <module>
    from mycodo.config import (CAMERA_INFO, DEPENDENCIES_GENERAL,
  File "/opt/Mycodo/mycodo/config.py", line 10, in <module>
    from flask_babel import lazy_gettext as lg
ModuleNotFoundError: No module named 'flask_babel'


I checked to ensure pip and pip3 were installed:

pi@CannaBot:~ $ pip --version
pip 24.2 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)
pi@CannaBot:~ $ pip3 --version
pip 24.2 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)


Please run python3 --version

pip installed via apt is not advised, which is why it’s uninstalled during the setup process and pip is installed via a better method. Try deleting /opt/Mycodo/env and rerunning sudo /opt/Mycodo/install/setup.sh

Python version:

pi@CannaBot:~ $ python3 --version
Python 3.8.0

After deleting /opt/Mycodo/env, and rerunning setup.sh, received following message:

pi@CannaBot:~ $ sudo /opt/Mycodo/install/setup.sh
## Currently installing with /opt/Mycodo/install/setup.sh
Checking Python version...
Python >= 3.6 found.

Error: dialog not installed. Install it then try the Mycodo setup again.

Install dialog and try again: apt install dialog

Install completed, but it seems we are still having an issue with pip.

#### Checking Python 3 virtual environment
#### Creating virtual environment at /opt/Mycodo/env
Error: Command '['/opt/Mycodo/env/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 2.

#### Updating pip

#### Checking Python 3 virtual environment
/opt/Mycodo/env/bin/python: No module named pip

#### Installing pip requirements

#### Checking Python 3 virtual environment
/opt/Mycodo/env/bin/python: No module named pip
/opt/Mycodo/env/bin/python: No module named pip

When I try just creating a virtual environment as a tutorial, there is the same issue.

pi@CannaBot:~ $ python -m venv tutorial-env
Error: Command '['/home/pi/tutorial-env/bin/python3.8', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 2.

I’d recommend using the established install instructions that specify the latest OS, rather than attempting to patch an outdated system.

1 Like

Yeah, I will just do a fresh install of Bookworm on this Pi and then a fresh install of Mycodo. Luckily I have a second unit that I swapped out to control the garden while I troubleshoot this unit. Thanks for all your help!

1 Like