pkg upgrade breaks app in Python venv

From: Dale Scott <dalescott_at_shaw.ca>
Date: Mon, 11 Apr 2022 21:23:40 UTC
Hi all, I have had trytond (the server daemon from the www.tryton.org Tryton project) running in a Python venv without issue for several months, but on the weekend did a pkg upgrade and now trytond fails during startup due to what I take to be a library version dependency error related to libxml2.

Do modules in a venv need to be upgraded after a system pkg upgrade? Is there a standard workflow I should follow?

Thanks for any assistance.

Dale

--- 
Dale Scott 
www.dalescott.net 
https://ca.linkedin.com/in/dalescott


System:

dale@starlord:~ % uname -a
FreeBSD starlord 13.0-RELEASE-p11 FreeBSD 13.0-RELEASE-p11 #0: Tue Apr  5 18:54:35 UTC 2022     root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64
dale@starlord:~ %


Error trying to start trytond after upgrading system packages:

Traceback (most recent call last):
  File "env/bin/trytond-cron", line 12, in <module>
    import trytond.commandline as commandline
  File "/usr/home/tryton/trytond/env/lib/python3.8/site-packages/trytond/__init__.py", line 8, in <module>
  File "env/bin/trytond-worker", line 12, in <module>
    from lxml import etree, objectify
ImportError: /usr/local/lib/libxml2.so.2: version LIBXML2_2.4.30 required by /usr/home/tryton/trytond/env/lib/python3.8/site-packages/lxml/etree.cpython-38.so not defined
    import trytond.commandline as commandline
  File "/usr/home/tryton/trytond/env/lib/python3.8/site-packages/trytond/__init__.py", line 8, in <module>
    from lxml import etree, objectify
ImportError: /usr/local/lib/libxml2.so.2: version LIBXML2_2.4.30 required by /usr/home/tryton/trytond/env/lib/python3.8/site-packages/lxml/etree.cpython-38.so not defined
Traceback (most recent call last):
  File "env/bin/trytond", line 15, in <module>
    import trytond.commandline as commandline
  File "/usr/home/tryton/trytond/env/lib/python3.8/site-packages/trytond/__init__.py", line 8, in <module>
    from lxml import etree, objectify
ImportError: /usr/local/lib/libxml2.so.2: version LIBXML2_2.4.30 required by /usr/home/tryton/trytond/env/lib/python3.8/site-packages/lxml/etree.cpython-38.so not defined


Modules installed in venv:

(env) [tryton@starlord ~/trytond]$ pip list
Package                       Version
----------------------------- ---------
certifi                       2021.10.8
charset-normalizer            2.0.9
defusedxml                    0.7.1
forex-python                  1.8
Genshi                        0.7.6
idna                          3.3
lxml                          4.8.0
passlib                       1.7.4
pip                           22.0.4
polib                         1.1.1
proteus                       6.2.2
psycopg2                      2.9.3
pycountry                     20.7.3
python-dateutil               2.8.2
python-magic                  0.4.25
python-sql                    1.3.0
python-stdnum                 1.17
relatorio                     0.10.0
requests                      2.27.1
setuptools                    56.0.0
simpleeval                    0.9.12
simplejson                    3.17.6
six                           1.16.0
sqlite3                       0.0.0
trytond                       6.2.6
trytond-account               6.2.5
trytond-account-invoice       6.2.3
trytond-account-invoice-stock 6.2.0
trytond-account-product       6.2.1
trytond-company               6.2.0
trytond-country               6.2.1
trytond-currency              6.2.0
trytond-party                 6.2.0
trytond-product               6.2.0
trytond-purchase              6.2.2
trytond-stock                 6.2.4
urllib3                       1.26.7
Werkzeug                      2.0.3
wrapt                         1.13.3
(env) [tryton@starlord ~/trytond]$

System pkgs that were upgraded (technically pkgs that _will_ be upgraded, the server is a vm and was reverted to a snapshot from just before the pkg upgrade).

dale@starlord:~ % sudo pkg upgrade
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking for upgrades (38 candidates): 100%
Processing candidates (38 candidates): 100%
The following 38 package(s) will be affected (of 0 checked):

Installed packages to be UPGRADED:
        bash: 5.1.12 -> 5.1.16
        ca_root_nss: 3.71 -> 3.76
        curl: 7.80.0 -> 7.82.0
        expat: 2.4.7 -> 2.4.8
        fontconfig: 2.13.94_1,1 -> 2.13.94_2,1
        git: 2.34.1 -> 2.35.1
        glib: 2.70.4,2 -> 2.70.4_2,2
        graphviz: 2.44.1_18 -> 2.50.0_1
        harfbuzz: 3.2.0 -> 4.2.0
        jpeg-turbo: 2.1.1_1 -> 2.1.3
        libedit: 3.1.20210216,1 -> 3.1.20210910,1
        libgd: 2.3.1,1 -> 2.3.3,1
        libglvnd: 1.4.0 -> 1.4.0_1
        libgpg-error: 1.43 -> 1.44
        libunistring: 0.9.10_1 -> 1.0
        libxml2: 2.9.12 -> 2.9.13
        libxslt: 1.1.34_2 -> 1.1.35_1
        llvm11: 11.0.1_4 -> 11.0.1_5
        npm-node17: 6.14.8_1 -> 8.5.2
        p5-CGI: 4.53 -> 4.54
        p5-GSSAPI: 0.28_1 -> 0.28_2
        p5-HTML-Parser: 3.76_1 -> 3.77
        p5-HTTP-Message: 6.35 -> 6.36
        p5-IO-Socket-SSL: 2.073 -> 2.074
        pango: 1.48.11 -> 1.50.6
        pcre: 8.45 -> 8.45_1
        pcre2: 10.39 -> 10.39_1
        postgresql14-client: 14.1 -> 14.2
        postgresql14-server: 14.1 -> 14.2
        py38-sqlite3: 3.8.12_7 -> 3.8.13_7
        python38: 3.8.12_1 -> 3.8.13
        readline: 8.1.1 -> 8.1.2
        sqlite3: 3.35.5_4,1 -> 3.37.2,1
        sudo: 1.9.8p2 -> 1.9.10
        tree: 1.8.0 -> 2.0.1
        webp: 1.2.1 -> 1.2.2
        wget: 1.21.2 -> 1.21.3

Installed packages to be REINSTALLED:
        libgcrypt-1.9.4 (options changed)

Number of packages to be upgraded: 37
Number of packages to be reinstalled: 1

The process will require 6 MiB more space.
177 MiB to be downloaded.

Proceed with this action? [y/N]: n
dale@starlord:~ %