Codecatalyst: problem when updating python 3.9 to 3.12

0

Hello, I want to update the version of python3 from 3.9 to 3.12 that I have in "CodeCatalyst". I need it to return "Python 3.12.4" instead of "Python 3.9.15" when I run <code>- Run: python3 --version</code>. I have successfully installed Python 3.12.4, but when I run <code>- Run: python3 --version</code>, it still returns "Python 3.9.15". I need it to be 3.12.4. Curiously, if I run <code>- Run: python3.12 --version</code>, it returns "Python 3.12.4", which is NOT what I need. Can someone help me to make the output of "python3 --version" be only "Python 3.12.4", please?

My .yaml file:

Name: onPushToMainDeploymentWorkflow SchemaVersion: "1.0" Compute: Type: EC2 Triggers:

  • Type: PUSH Branches:
    • main Actions: BackendTest: Identifier: test@v1 Inputs: Sources:
      • WorkflowSource Outputs: AutoDiscoverReports: IncludePaths:
        • "**/*" ExcludePaths:
        • "/.aws/workflows/" ReportNamePrefix: AutoDiscovered Enabled: true Configuration: Steps:
      • Run: echo "Python version $(python3 --version)" >> return 3.9.15
      • Run: yum update -y
      • Run: yum upgrade -y
      • Run: yum groupinstall "Development Tools" -y
      • Run: yum install gcc openssl-devel bzip2-devel libffi-devel -y --skip-broken
      • Run: cd /usr/src
      • Run: wget https://www.python.org/ftp/python/3.12.4/Python-3.12.4.tar.xz
      • Run: tar -xf Python-3.12.4.tar.xz
      • Run: cd Python-3.12.4
      • Run: ./configure --enable-optimizations
      • Run: make -j
      • Run: make install
      • Run: echo "Python version $(python3 --version)" >> return 3.9.15 ERROR: This is where I need it to be 3.12.4
      • Run: echo "Python version $(python3.12 --version)" >> return 3.12.4. It returns correct, but it doesn't work for me
asked 2 months ago240 views
1 Answer
2
Accepted Answer

Hello.

I think "/usr/bin/python3" is a symbolic link pointing to "Python 3.9.15".
So, I thought it would be a good idea to delete the symbolic link and then create a new symbolic link pointing to "Python 3.12".
Why not try setting up a symbolic link as shown below?

rm /usr/bin/python3
ln -s $(which python3.12) /usr/bin/python3
profile picture
EXPERT
answered 2 months ago
profile picture
EXPERT
reviewed 2 months ago
profile pictureAWS
EXPERT
reviewed 2 months ago
  • Hello Riku_Kobayashi, thank you very much for answering me. I tried your proposal but unfortunately it didn't work. Anyway, I continued researching and managed to find a solution, I don't remember where I found it because I was trying several hacks. The following solution worked for me:

    echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bashrc source ~/.bashrc echo "Python version $(python3 --version)" >> return 3.12.4 (is what I needed)

    And the complete flow looked like:

    • Run: echo "Python version $(python3 --version)" >> return 3.9.15
    • Run: yum update -y
    • Run: yum upgrade -y
    • Run: yum groupinstall "Development Tools" -y
    • Run: yum install gcc openssl-devel bzip2-devel libffi-devel -y --skip-broken
    • Run: cd /usr/src
    • Run: wget https://www.python.org/ftp/python/3.12.4/Python-3.12.4.tar.xz
    • Run: tar -xf Python-3.12.4.tar.xz
    • Run: cd Python-3.12.4
    • Run: ./configure --enable-optimizations
    • Run: make -j
    • Run: make install
    • Run: echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bashrc
    • Run: source ~/.bashrc
    • Run: echo "Python version $(python3 --version)" >> return 3.12.4 (is what I needed)

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions