Is it safe to upgrade pip?

My install always complains about pip being old whenever I update or install something. Appdaemon this last time.

WARNING: You are using pip version 22.0.4; however, version 22.2.2 is available.
You should consider upgrading via the '/usr/bin/python3.9 -m pip install --upgrade pip' command.

But at the same time I tried to upgrade pip in a testing install and HA complains about it has a pip dependency on v22.0.4.
So is it safe to upgrade pip? And what about other dependencies like:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
homeassistant 2022.6.2 requires bcrypt==3.1.7, but you have bcrypt 3.2.0 which is incompatible.
homeassistant 2022.6.2 requires jinja2==3.1.2, but you have jinja2 3.0.3 which is incompatible.
homeassistant 2022.6.2 requires requests==2.27.1, but you have requests 2.26.0 which is incompatible.
homeassistant 2022.6.2 requires voluptuous==0.13.1, but you have voluptuous 0.12.2 which is incompatible.

I have Home Assistant manually installed in a linux container.

Edit:

$ pip install requests --upgrade
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: requests in /home/homeassistant/.local/lib/python3.9/site-packages (2.26.0)
Collecting requests
  Using cached requests-2.28.1-py3-none-any.whl (62 kB)
Requirement already satisfied: certifi>=2017.4.17 in /home/homeassistant/.local/lib/python3.9/site-packages (from requests) (2022.5.18.1)
Requirement already satisfied: charset-normalizer<3,>=2 in /usr/local/lib/python3.9/dist-packages (from requests) (2.0.12)
Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3/dist-packages (from requests) (2.10)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/lib/python3/dist-packages (from requests) (1.26.5)
Installing collected packages: requests
  Attempting uninstall: requests
    Found existing installation: requests 2.26.0
    Uninstalling requests-2.26.0:
      Successfully uninstalled requests-2.26.0
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
homeassistant 2022.6.2 requires bcrypt==3.1.7, but you have bcrypt 3.2.0 which is incompatible.
homeassistant 2022.6.2 requires jinja2==3.1.2, but you have jinja2 3.0.3 which is incompatible.
homeassistant 2022.6.2 requires requests==2.27.1, but you have requests 2.28.1 which is incompatible.
homeassistant 2022.6.2 requires voluptuous==0.13.1, but you have voluptuous 0.12.2 which is incompatible.
appdaemon 4.2.1 requires requests==2.26.0, but you have requests 2.28.1 which is incompatible.
Successfully installed requests-2.28.1
WARNING: You are using pip version 22.0.4; however, version 22.2.2 is available.
You should consider upgrading via the '/usr/bin/python3.9 -m pip install --upgrade pip' command.

I don’t think I understand. HA is not forward compatible?

Ok, I upgraded HA and now the problem is only appdaemon.

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
appdaemon 4.2.1 requires bcrypt==3.2.0, but you have bcrypt 3.1.7 which is incompatible.
appdaemon 4.2.1 requires Jinja2==3.0.3, but you have jinja2 3.1.2 which is incompatible.
appdaemon 4.2.1 requires requests==2.26.0, but you have requests 2.28.1 which is incompatible.
appdaemon 4.2.1 requires voluptuous==0.12.2, but you have voluptuous 0.13.1 which is incompatible.

But the first question still remains

Hopefully you’ve got AppDaemon and HA in their own virtual environment (venv). If so upgrading pip for AppDaemon won’t impact HA.

Generally speaking don’t upgrade any Python package in your HA venv, if it needs upgraded then it’ll be in the requirements and handled automatically.

Errr… wait. I just installed appdaemon as root and run as user homeassistant as instructed in the appdaemon’s documentation

I installed HA like:
# sudo -u homeassistant -H -s

$ history
    1  cd /srv/homeassistant
    2  python3.9 -m venv .
    3  source bin/activate
    4  python3 -m pip install wheel
    5  pip3 install homeassistant

And was upgrading it:
# sudo -u homeassistant -H -s

   $  source /srv/homeassistant/bin/activate
   $  pip3 install --upgrade homeassistant

But this last time I only did:

   $  pip3 install --upgrade homeassistant

Will this be a problem?

The only problem I have with this is that I wanted to create a builder script for raising the LXC under proxmox but I don’t know how to execute all those commands like homeassistant user and the venv.

EDIT:
I did uninstall appdaemon and installed like:

mkdir -p /srv/appdaemon
chown homeassistant:homeassistant /srv/appdaemon
sudo -u homeassistant -H -s

# Run as homeassistant user
cd /srv/appdaemon
python3 -m venv .
source bin/activate
pip3 install appdaemon
exit
# Back to root

cat > /etc/systemd/system/[email protected] << EOF
[Unit]
Description=AppDaemon
[email protected]
[email protected]
[Service]  
Type=simple
User=homeassistant
ExecStart=/srv/appdaemon/bin/appdaemon -c /home/homeassistant/.homeassistant/appdaemon
[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable [email protected] --now
systemctl start [email protected]

The question is: If I would want to execute this as a install script, for raising lxc container, how I would execute the part run as homeassistant user?

Home Assistant is in a venv, that bit is fine.

    2  python3.9 -m venv .

that’s the step where you created the venv.

cd /srv/appdaemon
python3 -m venv .

and that’s where you created one for AppDaemon.

Maybe you should consider running at least Home Assistant in Docker instead?

Then to subsequent upgrades to HA/appdaemon is not required to activate the venv with source /srv/homeassistant/bin/activate ?
Sorry, I’m a bit lost with this.

I was running it on docker. But on a proxmox system that was creating a good amount of overhead. I migrated to a lxc container and was surprised with the results. So I ended migrating all my services to LXC. There was a big improvement, compared to VMS with docker.

BTW… thant you very much @Tinkerer. I almost forgot to thank you. :sweat_smile:

Yes, you need to activate the venv, as the right user, before upgrading - see the HA docs.

The problem wasn’t the overhead of Docker (which is effectively zero), but the overhead of the VM.

I’ll add as an FYI, I get the pip newer version is available warning from time to time when upgrading HA,
and I check this link to see what versions of pip can be used for HA upgrades (currently this is shown at around line 30: pip>=21.0,<22.3)