[GH-ISSUE #1772] Upgrading to Debian 10 Buster #1396

Closed
opened 2026-02-27 11:16:53 +03:00 by kerem · 5 comments
Owner

Originally created by @stathis on GitHub (Aug 29, 2019).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/1772

I recently upgraded one of my machines to Debian 10 Buster. Some things like Statistics and DKIM regeneration, record monitoring etc have stopped working.

When trying to invoke such scripts (usually ran by cron) manually, errors like the following occur:

root@mail:~# $PYTHON $INSTANCE/manage.py modo check_mx
Traceback (most recent call last):
  File "/srv/modoboa/instance/manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 10, in <module>
    from django.apps import apps
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/apps/__init__.py", line 1, in <module>
    from .config import AppConfig
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/apps/config.py", line 4, in <module>
    from django.core.exceptions import ImproperlyConfigured
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/exceptions.py", line 5, in <module>
    from django.utils.encoding import force_text
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/utils/encoding.py", line 10, in <module>
    from django.utils.functional import Promise
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 1, in <module>
    import copy
  File "/usr/lib/python2.7/copy.py", line 52, in <module>
    import weakref
  File "/usr/lib/python2.7/weakref.py", line 14, in <module>
    from _weakref import (
ImportError: cannot import name _remove_dead_weakref

Has anyone experienced such errors, and if so, is there a solution?

Thank you in advance.

Impacted versions

  • Modoboa: Latest
  • installer used: Yes
  • Webserver: Nginx

Steps to reproduce

Upgrade from Debian 9.9 to 10.

Current behavior

Most cron scripts fail at runtime. Statistics do not update, DKIM keys do not regenerate.

Expected behavior

Above things stated to actually work.

Originally created by @stathis on GitHub (Aug 29, 2019). Original GitHub issue: https://github.com/modoboa/modoboa/issues/1772 I recently upgraded one of my machines to Debian 10 Buster. Some things like Statistics and DKIM regeneration, record monitoring etc have stopped working. When trying to invoke such scripts (usually ran by cron) manually, errors like the following occur: ``` root@mail:~# $PYTHON $INSTANCE/manage.py modo check_mx Traceback (most recent call last): File "/srv/modoboa/instance/manage.py", line 8, in <module> from django.core.management import execute_from_command_line File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 10, in <module> from django.apps import apps File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/apps/__init__.py", line 1, in <module> from .config import AppConfig File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/apps/config.py", line 4, in <module> from django.core.exceptions import ImproperlyConfigured File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/exceptions.py", line 5, in <module> from django.utils.encoding import force_text File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/utils/encoding.py", line 10, in <module> from django.utils.functional import Promise File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 1, in <module> import copy File "/usr/lib/python2.7/copy.py", line 52, in <module> import weakref File "/usr/lib/python2.7/weakref.py", line 14, in <module> from _weakref import ( ImportError: cannot import name _remove_dead_weakref ``` Has anyone experienced such errors, and if so, is there a solution? Thank you in advance. # Impacted versions * Modoboa: Latest * installer used: Yes * Webserver: Nginx # Steps to reproduce Upgrade from Debian 9.9 to 10. # Current behavior Most cron scripts fail at runtime. Statistics do not update, DKIM keys do not regenerate. # Expected behavior Above things stated to actually work.
kerem closed this issue 2026-02-27 11:16:53 +03:00
Author
Owner

@Toniob commented on GitHub (Aug 29, 2019):

Hi there,
During the update, your python has been upgraded. And now your virtualenv is probably broken. You have to setup it again, to update the links with the debian packaged python.

<!-- gh-comment-id:526083311 --> @Toniob commented on GitHub (Aug 29, 2019): Hi there, During the update, your python has been upgraded. And now your virtualenv is probably broken. You have to setup it again, to update the links with the debian packaged python.
Author
Owner

@stathis commented on GitHub (Aug 29, 2019):

Thank you for your answer.

So would this in theory, be enough: https://gist.github.com/tevino/1a557a0c200d61d4e4fb

<!-- gh-comment-id:526084471 --> @stathis commented on GitHub (Aug 29, 2019): Thank you for your answer. So would this in theory, be enough: https://gist.github.com/tevino/1a557a0c200d61d4e4fb
Author
Owner

@Toniob commented on GitHub (Aug 29, 2019):

It may works. Just be sure to backup your current directory before.

<!-- gh-comment-id:526090469 --> @Toniob commented on GitHub (Aug 29, 2019): It may works. Just be sure to backup your current directory before.
Author
Owner

@stathis commented on GitHub (Aug 29, 2019):

I ran a script like the one I linked, like this inside the virtualenv:

#!/usr/bin/env bash
ENV_PATH="$(dirname "$(dirname "$(which pip)")")"
SYSTEM_VIRTUALENV="$(which -a virtualenv|tail -1)"

echo "Ensure the root of current virtualenv:"
echo "    $ENV_PATH"
read -p "‼️  Say no if you are not sure (y/N) " -n 1 -r
echo
PYEXC_DEF="$(sed -n '1s/^#!//p' $SYSTEM_VIRTUALENV)"
read -p "🐍   Choose which python to use? [$PYEXC_DEF] " PYEXC
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
    echo "♻️  Removing old symbolic links......"
    find "$ENV_PATH" -type l -delete -print
    echo "💫   Creating new symbolic links......"
    $SYSTEM_VIRTUALENV "$ENV_PATH" -p ${PYEXC:-$PYEXC_DEF}
    echo "🎉   Done!"
fi

Just one catch, I had to use the python 2.7 binary. Restarted uwsgi afterwards and all is fine.

<!-- gh-comment-id:526209091 --> @stathis commented on GitHub (Aug 29, 2019): I ran a script like the one I linked, like this inside the virtualenv: ``` #!/usr/bin/env bash ENV_PATH="$(dirname "$(dirname "$(which pip)")")" SYSTEM_VIRTUALENV="$(which -a virtualenv|tail -1)" echo "Ensure the root of current virtualenv:" echo " $ENV_PATH" read -p "‼️ Say no if you are not sure (y/N) " -n 1 -r echo PYEXC_DEF="$(sed -n '1s/^#!//p' $SYSTEM_VIRTUALENV)" read -p "🐍 Choose which python to use? [$PYEXC_DEF] " PYEXC echo if [[ $REPLY =~ ^[Yy]$ ]]; then echo "♻️ Removing old symbolic links......" find "$ENV_PATH" -type l -delete -print echo "💫 Creating new symbolic links......" $SYSTEM_VIRTUALENV "$ENV_PATH" -p ${PYEXC:-$PYEXC_DEF} echo "🎉 Done!" fi ``` Just one catch, I had to use the python 2.7 binary. Restarted uwsgi afterwards and all is fine.
Author
Owner

@xagaba commented on GitHub (Sep 25, 2019):

How/Where do you run this script ? and with wich user ?

<!-- gh-comment-id:534977599 --> @xagaba commented on GitHub (Sep 25, 2019): How/Where do you run this script ? and with wich user ?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#1396
No description provided.