When I got this server assigned, it has two versions of python (2.7 and 3.6), then I had to install 3.10 manually because the version of Netbox I want to use needed 3.8 minimum.
Everything looked fine, until I realized that walinuxagent
(Azure Linux Agent) is not working. It seems there's an issue with python.
Azure Linux Agent
- I have
apt remove --purge walinuxagent
and reinstalled viaapt install walinuxagent
but still not working:
$ sudo systemctl status walinuxagent.service
● walinuxagent.service - Azure Linux Agent
Loaded: loaded (/lib/systemd/system/walinuxagent.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/walinuxagent.service.d
└─10-Slice.conf, 11-CPUAccounting.conf, 12-CPUQuota.conf
Active: failed (Result: exit-code) since Wed 2023-02-01 15:19:50 UTC; 15s ago
Process: 29518 ExecStart=/usr/bin/python3 -u /usr/sbin/waagent -daemon (code=exited, status=1/FAILURE)
Main PID: 29518 (code=exited, status=1/FAILURE)
CPU: 76ms
Feb 01 15:19:50 SERVER-01 systemd[1]: walinuxagent.service: Service hold-off time over, scheduling restart.
Feb 01 15:19:50 SERVER-01 systemd[1]: walinuxagent.service: Scheduled restart job, restart counter is at 5.
Feb 01 15:19:50 SERVER-01 systemd[1]: Stopped Azure Linux Agent.
Feb 01 15:19:50 SERVER-01 systemd[1]: walinuxagent.service: Consumed 76ms CPU time
Feb 01 15:19:50 SERVER-01 systemd[1]: walinuxagent.service: Start request repeated too quickly.
Feb 01 15:19:50 SERVER-01 systemd[1]: walinuxagent.service: Failed with result 'exit-code'.
Feb 01 15:19:50 SERVER-01 systemd[1]: Failed to start Azure Linux Agent.
- This is the result of
journalctl -u walinuxagent.service
:
-- Logs begin at Thu 2022-12-15 11:18:50 UTC, end at Wed 2023-02-01 15:28:33 UTC. --
Jan 31 10:03:55 SERVER-01 systemd[1]: Started Azure Linux Agent.
Jan 31 10:03:55 SERVER-01 python3[930]: /usr/sbin/waagent:27: DeprecationWarning: the imp module is deprecated in favour
Jan 31 10:03:55 SERVER-01 python3[930]: import imp
Jan 31 10:03:56 SERVER-01 python3[930]: Traceback (most recent call last):
Jan 31 10:03:56 SERVER-01 python3[930]: File "/usr/lib/python3/dist-packages/azurelinuxagent/common/future.py", line 43Jan 31 10:03:56 SERVER-01 python3[930]: supported = platform._supported_dists + (supported_dists,)
Jan 31 10:03:56 SERVER-01 python3[930]: AttributeError: module 'platform' has no attribute '_supported_dists'
Jan 31 10:03:56 SERVER-01 python3[930]: During handling of the above exception, another exception occurred:
Jan 31 10:03:56 SERVER-01 python3[930]: Traceback (most recent call last):
Jan 31 10:03:56 SERVER-01 python3[930]: File "/usr/sbin/waagent", line 31, in <module>
Jan 31 10:03:56 SERVER-01 python3[930]: import azurelinuxagent.agent as agent
Jan 31 10:03:56 SERVER-01 python3[930]: File "/usr/lib/python3/dist-packages/azurelinuxagent/agent.py", line 34, in <moJan 31 10:03:56 SERVER-01 python3[930]: import azurelinuxagent.common.event as event
Jan 31 10:03:56 SERVER-01 python3[930]: File "/usr/lib/python3/dist-packages/azurelinuxagent/common/event.py", line 34,Jan 31 10:03:56 SERVER-01 python3[930]: from azurelinuxagent.common.version import CURRENT_VERSION, CURRENT_AGENT
Jan 31 10:03:56 SERVER-01 python3[930]: File "/usr/lib/python3/dist-packages/azurelinuxagent/common/version.py", line 1Jan 31 10:03:56 SERVER-01 python3[930]: __distro__ = get_distro()
Jan 31 10:03:56 SERVER-01 python3[930]: File "/usr/lib/python3/dist-packages/azurelinuxagent/common/version.py", line 8Jan 31 10:03:56 SERVER-01 python3[930]: osinfo = get_linux_distribution(0, 'alpine')
Jan 31 10:03:56 SERVER-01 python3[930]: File "/usr/lib/python3/dist-packages/azurelinuxagent/common/future.py", line 61Jan 31 10:03:56 SERVER-01 python3[930]: return get_linux_distribution_from_distro(get_full_name)
Jan 31 10:03:56 SERVER-01 python3[930]: File "/usr/lib/python3/dist-packages/azurelinuxagent/common/future.py", line 72Jan 31 10:03:56 SERVER-01 python3[930]: distro.linux_distribution(
Jan 31 10:03:56 SERVER-01 python3[930]: NameError: name 'distro' is not defined
Jan 31 10:03:56 SERVER-01 systemd[1]: walinuxagent.service: Main process exited, code=exited, status=1/FAILURE
Jan 31 10:03:56 SERVER-01 systemd[1]: walinuxagent.service: Failed with result 'exit-code'.
Jan 31 10:03:56 SERVER-01 systemd[1]: walinuxagent.service: Consumed 125ms CPU time
Jan 31 10:03:56 SERVER-01 systemd[1]: walinuxagent.service: Service hold-off time over, scheduling restart.
Jan 31 10:03:56 SERVER-01 systemd[1]: walinuxagent.service: Scheduled restart job, restart counter is at 1.
Jan 31 10:03:56 SERVER-01 systemd[1]: Stopped Azure Linux Agent.
- I also tried to install manually, downloaded the agent from the official Azure Linux Agent git page:
$ sudo python3 setup.py install
Traceback (most recent call last):
File "/home/admin/Azure/WALinuxAgent-master/setup.py", line 24, in <module>
import setuptools
File "/usr/lib/python3/dist-packages/setuptools/init.py", line 12, in <module>
import setuptools.version
File "/usr/lib/python3/dist-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 77, in <module>
import('pkg_resources.extern.packaging.requirements')
File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/packaging/requirements.py", line 9, in <module>
from pkg_resources.extern.pyparsing import stringStart, stringEnd, originalTextFor, ParseException
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 672, in _load_unlocked
File "<frozen importlib._bootstrap>", line 632, in _load_backward_compatible
File "/usr/lib/python3/dist-packages/pkg_resources/extern/init.py", line 43, in load_module
import(extant)
File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/pyparsing.py", line 943, in <module>
collections.MutableMapping.register(ParseResults)
AttributeError: module 'collections' has no attribute 'MutableMapping'
Python
whereis python
output:
python: /usr/bin/python3.6m-config /usr/bin/python3.10 /usr/bin/python3.6-config /usr/bin/python /usr/bin/python3.6m /usr/bin/python3.6 /usr/bin/python2.7 /usr/lib/python3.10 /usr/lib/python3.8 /usr/lib/python3.6 /usr/lib/python2.7 /usr/lib/python3.7 /etc/python3.10 /etc/python /etc/python3.6 /etc/python2.7 /usr/local/lib/python3.10 /usr/local/lib/python3.6 /usr/local/lib/python2.7 /usr/include/python3.6m /usr/include/python3.6 /usr/share/python /usr/share/man/man1/python.1.gz
ls -ls /usr/bin/python*
output:
0 lrwxrwxrwx 1 root root 24 Jan 31 15:53 /usr/bin/python -> /etc/alternatives/python
0 lrwxrwxrwx 1 root root 9 Apr 16 2018 /usr/bin/python2 -> python2.7
3544 -rwxr-xr-x 1 root root 3628904 Nov 28 18:51 /usr/bin/python2.7
0 lrwxrwxrwx 1 root root 25 Dec 15 10:41 /usr/bin/python3 -> /etc/alternatives/python3
0 lrwxrwxrwx 1 root root 16 Oct 25 2018 /usr/bin/python3-config -> python3.6-config
4 -rwxr-xr-x 1 root root 1018 Oct 28 2017 /usr/bin/python3-jsondiff
4 -rwxr-xr-x 1 root root 3661 Oct 28 2017 /usr/bin/python3-jsonpatch
4 -rwxr-xr-x 1 root root 1342 May 1 2016 /usr/bin/python3-jsonpointer
4 -rwxr-xr-x 1 root root 398 Nov 15 2017 /usr/bin/python3-jsonschema
5352 -rwxr-xr-x 1 root root 5477688 Jan 28 19:09 /usr/bin/python3.10
4424 -rwxr-xr-x 2 root root 4526456 Nov 25 14:10 /usr/bin/python3.6
0 lrwxrwxrwx 1 root root 33 Nov 25 14:10 /usr/bin/python3.6-config -> x86_64-linux-gnu-python3.6-config
4424 -rwxr-xr-x 2 root root 4526456 Nov 25 14:10 /usr/bin/python3.6m
0 lrwxrwxrwx 1 root root 34 Nov 25 14:10 /usr/bin/python3.6m-config -> x86_64-linux-gnu-python3.6m-config
0 lrwxrwxrwx 1 root root 10 Oct 25 2018 /usr/bin/python3m -> python3.6m
0 lrwxrwxrwx 1 root root 17 Oct 25 2018 /usr/bin/python3m-config -> python3.6m-config
- Python version listed:
$ python -V
Python 3.10.9
$ python3 -V
Python 3.10.9
$ update-alternatives --list python
/usr/bin/python2.7
/usr/bin/python3.10
Does anyone have an idea of how can I resolve this?
UPDATE 1: the situation improved
I uninstalled Python 3.10.9, removed the symlinks and replaced with the python version that originally came with the OS, then I reconfigured update-alternatives
of python
and python3
.
$ ls -ls /usr/bin/python*
0 lrwxrwxrwx 1 root root 24 Feb 2 10:22 /usr/bin/python -> /etc/alternatives/python
0 lrwxrwxrwx 1 root root 9 Apr 16 2018 /usr/bin/python2 -> python2.7
3544 -rwxr-xr-x 1 root root 3628904 Nov 28 18:51 /usr/bin/python2.7
0 lrwxrwxrwx 1 root root 25 Feb 2 10:23 /usr/bin/python3 -> /etc/alternatives/python3
0 lrwxrwxrwx 1 root root 16 Oct 25 2018 /usr/bin/python3-config -> python3.6-config
4 -rwxr-xr-x 1 root root 1018 Oct 28 2017 /usr/bin/python3-jsondiff
4 -rwxr-xr-x 1 root root 3661 Oct 28 2017 /usr/bin/python3-jsonpatch
4 -rwxr-xr-x 1 root root 1342 May 1 2016 /usr/bin/python3-jsonpointer
4 -rwxr-xr-x 1 root root 398 Nov 15 2017 /usr/bin/python3-jsonschema
4424 -rwxr-xr-x 2 root root 4526456 Nov 25 14:10 /usr/bin/python3.6
0 lrwxrwxrwx 1 root root 33 Nov 25 14:10 /usr/bin/python3.6-config -> x86_64-linux-gnu-python3.6-config
4424 -rwxr-xr-x 2 root root 4526456 Nov 25 14:10 /usr/bin/python3.6m
0 lrwxrwxrwx 1 root root 34 Nov 25 14:10 /usr/bin/python3.6m-config -> x86_64-linux-gnu-python3.6m-config
0 lrwxrwxrwx 1 root root 10 Oct 25 2018 /usr/bin/python3m -> python3.6m
0 lrwxrwxrwx 1 root root 17 Oct 25 2018 /usr/bin/python3m-config -> python3.6m-config
$ python -V
Python 2.7.17
$ python3 -V
Python 3.6.9
- Now
walinuxagent
is running fine.
$ sudo systemctl status walinuxagent
● walinuxagent.service - Azure Linux Agent
Loaded: loaded (/lib/systemd/system/walinuxagent.service; enabled; vendor preset: enabled)
Drop-In: /lib/system/system/walinuxagent.service.d
└─10-Slice.conf, 11-CPUAccounting.conf, 12-CPUQuota.conf, 13-MemoryAccounting.conf
Active: active (running) since Thu 2023-02-02 10:29:31 UTC; 5s ago
Main PID: 10593 (python3)
Tasks: 7 (limit: 4915)
Memory: 32.4M
CPU: 920ms
CGroup: /azure.slice/walinuxagent.service
├─10593 /usr/bin/python3 -u /usr/sbin/waagent -daemon
└─10632 python3 -u bin/WALinuxAgent-2.9.0.4-py2.7.egg -run-exthandlers
the problem is that I need to upgrade fron pythoin 3.6 to python 3.8, 3.9, 3.10 or 3.11, without messing things up
UPDATE 2: A new issue
I managed to install python 3.6
alongside python 3.10
, the problem is that when 3.6 is selected in update alternatives, walinuxagent
service works fine when while netbox
, netbox-rq
and nginx
services doesn't; the opposite happening when 3.10 is selected.
A workaround is selecting each python version depending on which service I want to start. Is there a way to avoiding doing this every time?
update-alternatives --config python
? – FeDos Feb 02 '23 at 14:02update-alternatives --config python
because a lot of apps depend on the original Python version. – karel Feb 02 '23 at 14:06