Score:0

Upgrade to Python3.9 cannot ssh to the Ubuntu EC2 instance

gh flag

I'm creating a custom AMI using packer and ansible. The base AMI is an Ubuntu 20.04 provided by the Canonical and it's customized using an ansible playbook. I'm installing python3.9 and setting it as the default python:

        - name: Setup Python3.9 As Default Python Interpreter
      shell: |
          sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
          sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2

Each EC2 instance based on this AMI is unreachable via ssh (I have installed openssh-server and placed the keys). Once the instance is rebooted I can ssh to the server. The issue seams to be with the cloud-init package that is not working with python3.9. What did I try?

  1. Disable the cloud-init package - no ssh connection even after the reboot
  2. Manually install the latest version of cloud-init - no ssh on the initial boot, ssh after the reboot worked. Got this error - ubuntu@ip-XXX-XX-XX-XXX:~$ docker Traceback (most recent call last): File "/usr/lib/command-not-found", line 28, in <module> from CommandNotFound import CommandNotFound File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module> from CommandNotFound.db.db import SqliteDatabase File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module> import apt_pkg ModuleNotFoundError: No module named 'apt_pkg'
guiverc avatar
cn flag
Don't forget if you change the *default* python3 version; all Ubuntu tools that rely on that may misbehave which leads to two results (a) they won't work (best outcome) or (b) in rare cases corruption. If you change default python3, you can't use user tools like `apt` etc being limited to tools that don't use python3! Unless you're very aware of your Ubuntu system & thus what you can/cannot use, **do not change the default python3** where you value your data.
guiverc avatar
cn flag
Does this answer your question? [How to change python3 from python3.5 to python3.6](https://askubuntu.com/questions/900493/how-to-change-python3-from-python3-5-to-python3-6)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.