Unable to change mail settings of the domain: Error: spammng failed: ImportError: No module named contextlib

Created:

2017-04-12 13:47:17 UTC

Modified:

2017-08-08 13:17:41 UTC

0

Was this article helpful?


Have more questions?

Submit a request

Unable to change mail settings of the domain: Error: spammng failed: ImportError: No module named contextlib

Applicable to:

  • Plesk 12.5 for Linux

Symptoms

  • When trying to change to change mail settings for the domain (for example, change mailbox password), the following error is shown in Plesk interface:

    Error: spammng failed: Traceback (most recent call last):
    File "/opt/psa/admin/sbin/spammng", line 5, in <module>
    import spammng
    File "/opt/psa/lib/modules/python/spammng/spammng.py", line 18, in <module>
    import plesk_service
    File "/opt/psa/admin/lib/python/plesk_service.py", line 7, in <module>
    from plesk_interproc_locks import InterProcessLock
    File "/opt/psa/admin/lib/python/plesk_interproc_locks.py", line 10, in <module>
    from contextlib import contextmanager
    ImportError: No module named contextlib
    Error in sys.excepthook:
    Traceback (most recent call last):
    File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 66, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
    File "/usr/lib/python2.7/dist-packages/apport/__init__.py", line 1, in <module>
    from apport.report import Report
    File "/usr/lib/python2.7/dist-packages/apport/report.py", line 18, in <module>
    import problem_report
    File "/usr/lib/python2.7/dist-packages/problem_report.py", line 14, in <module>
    import zlib, base64, time, sys, gzip, struct, os
    File "/usr/lib/python2.7/gzip.py", line 10, in <module>
    import io
    File "/usr/lib/python2.7/io.py", line 51, in <module>
    import _io
    ImportError: /usr/lib/python2.7/lib-dynload/_io.so: undefined symbol: _PyErr_ReplaceException

    Original exception was:
    Traceback (most recent call last):
    File "/opt/psa/admin/sbin/spammng", line 5, in <module>
    import spammng
    File "/opt/psa/lib/modules/python/spammng/spammng.py", line 18, in <module>
    import plesk_service
    File "/opt/psa/admin/lib/python/plesk_service.py", line 7, in <module>
    from plesk_interproc_locks import InterProcessLock
    File "/opt/psa/admin/lib/python/plesk_interproc_locks.py", line 10, in <module>
    from contextlib import contextmanager
    ImportError: No module named contextlib
  • Unable to check SpamAssassin status from the CLI using plesk sbin spammng --status command - the same error is shown.

  • Other Plesk command-line utilities which use Python (for example, f2bmng , phpinimng or sslmng ) are also broken with the similar errors.

Cause

Custom Python packages were manually and incorrectly installed into the system:

# dpkg -l | grep python
iU libpython2.7          2.7.12-1~precise1          Shared Python runtime library (version 2.7)
ii python                2.7.3-0ubuntu2.2           interactive high-level object-oriented language (default version)
ii python-minimal        2.7.3-0ubuntu2.2           minimal subset of the Python language (default version)
iU python2.7             2.7.12-1~precise1          Interactive high-level object-oriented language (version 2.7)
ii python2.7-minimal     2.7.3-0ubuntu3.9           Minimal subset of the Python language (version 2.7)

Resolution

  1. Remove custom Python packages:

    # dpkg --purge --force-all python2.7
    # dpkg --purge --force-all libpython2.7
  2. Update the package lists and reinstall python2.7 and libpython2.7 packages from the default Ubuntu/Debian repositories:

    # apt-get update
    # apt-get -f install
Have more questions? Submit a request
Please sign in to leave a comment.