2

I have Python 3.4 installed on my Linux computer.

sudo apt-get install python3.4

However, when I run python -V, it shows that Python 2.7.6 is being used.

How do I tell the system to use the updated version of Python?

The answer to this question for a windows computer is at How to update version of Python?, but I couldn't find an answer for Linux.

1
  • 2
    Specify the new executable: python3.4 -V Commented Mar 16, 2016 at 6:33

3 Answers 3

4

On Linux, installations of python3 installed by the package manager (e.g. apt) can be called as python3. You might need to specify the version - e.g. python3.5 if the package manager has installed more than one, or you've compiled your own installations from source.

Sign up to request clarification or add additional context in comments.

Comments

2

you can specify the version in the shebang. write #!/usr/bin/env python3.

when run via ./my_script.py it will run in python3.

otherwise run it via python3 my_script.py.

if you just want to start an interactive python shell start it with python3

you also can be more specific with the version. just replace python3 with python3.4 (if installed)

Comments

2

In ubuntu various python executable are places under /usr/bin/ and might look like

/usr/bin/python
/usr/bin/python3.2
/usr/bin/python3.4

etc. so when you execute a command python -v it looks for a file with that name in that location. so to choose your version specify it like python3.4 -v

you can replace the simlink /usr/lib/python with /usr/bin/python3.4 to make that "default"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.