tox AttributeError: module 'virtualenv.create.via_global_ref.builtin.cpython.mac_os' has no attribute 'CPython2macOsArmFramework' beheben

Problem:

Beim Versuch, Python-Tests mit tox auszuführen, siehst du eine Fehlermeldung wie

tox_virtualenv_error.txt
GLOB sdist-make: /home/uli/dev/UliEngineering/setup.py
py37 create: /home/uli/dev/UliEngineering/.tox/py37
ERROR: InterpreterNotFound: python3.7
py38 create: /home/uli/dev/UliEngineering/.tox/py38
ERROR: invocation failed (exit code 1), logfile: /home/uli/dev/UliEngineering/.tox/py38/log/py38-0.log
========================================================================================= log start =========================================================================================
AttributeError: module 'virtualenv.create.via_global_ref.builtin.cpython.mac_os' has no attribute 'CPython2macOsArmFramework'

========================================================================================== log end ==========================================================================================
ERROR: InvocationError for command /usr/bin/python3 -m virtualenv --no-download --python /usr/bin/python3 py38 (exited with code 1)
__________________________________________________________________________________________ summary __________________________________________________________________________________________
ERROR:  py37: InterpreterNotFound: python3.7
ERROR:   py38: InvocationError for command /usr/bin/python3 -m virtualenv --no-download --python /usr/bin/python3 py38 (exited with code 1)

Lösung

Dieser Fehler tritt auf, weil zwei verschiedene und inkompatible Versionen von virtualenv installiert sind.

Deinstalliere zunächst alle Versionen mit diesen Befehlen:

Führe zuerst als Benutzer (nicht als root) aus, um alle lokal installierten Pakete in ~/.local zu deinstallieren:

pip_uninstall_virtualenv.sh
pip uninstall virtualenv

Deinstalliere dann globale Pakete

sudo_pip_uninstall_virtualenv.sh
sudo pip uninstall virtualenv

Deinstalliere nun das apt-Paket auf Debian/Ubuntu (deinstalliere mit deinem Paketmanager für andere Distributionen):

apt_purge_virtualenv.sh
sudo apt purge python3-virtualenv

Nun ist es Zeit, nur eine Version von virtualenv zu installieren:

pip_install_virtualenv.sh
pip install -U virtualenv

Danach kannst du versuchen, tox erneut auszuführen.


Check out similar posts by category: Python