-1

I am new to ubuntu and I wanted to shift my version to Python 3.4.1.

So I ran the command:

$ sudo update-alternatives --config python
update-alternatives: error: no alternatives for python

But then I try to run command:

$ sudo apt-get install python3.4
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3.4 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.

I don't know how to switch between the versions. Please help.

1
  • Currently Python3.4 is offered in the Ubuntu PPA's - to get 3.4.1 you will need to download it from python.org, and install it from the sourced. Jun 25, 2014 at 4:27

2 Answers 2

1

python 2.7 and python 3.4 is already preinstalled on your Ubuntu 14.04.

  • Run python3 command on terminal to get python3 interpreter.

  • Run python command on terminal to get python2 interpreter.

4
  • Thank you so much. How do I set python 3.4.1 as my default?
    – sandhus
    Jun 25, 2014 at 1:31
  • 1
    Got the answer askubuntu.com/questions/320996/…
    – sandhus
    Jun 25, 2014 at 1:33
  • 1
    @sandhus I don't think you're supposed to. It's the official python recommendation that python refer to python2.x and python3 refer to python3.x. Forcing it to be otherwise can cause problems in Python-based software in your system. Just call python3 when you want to run interactively, and use #! /usr/bin/python3 as the shebang in Python scripts you write.
    – muru
    Jun 25, 2014 at 1:34
  • Thank you muru. I didnt really think about it. Makes sense.
    – sandhus
    Jun 25, 2014 at 2:19
1

Take at look at virtualenv and virtualenvwrapper. They'll allow you to set up an "environment" with one version of python. What's nice is you can pip install packages under that environment and then switch to another environment with a different set of packages installed - essentially running different versions of python without conflicts of libraries.

Ref: http://docs.python-guide.org/en/latest/dev/virtualenvs/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .