Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
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. –  Charles Green Jun 25 at 4:27

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
    
Thank you so much. How do I set python 3.4.1 as my default? –  sandhus Jun 25 at 1:31
1  
Got the answer askubuntu.com/questions/320996/… –  sandhus Jun 25 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 at 1:34
    
Thank you muru. I didnt really think about it. Makes sense. –  sandhus Jun 25 at 2:19

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/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.