Making python 3.3 default python 3 interpreter instead of 3.2

10,024

Solution 1

You can custom your python3 alias. For this, you can modify your .bashrc file by appending "alias python3='python3.3'" at the end of it. This shell script can do it for you :

#!/bin/bash

cd ~

# Create the ~/.bashrc file if it does not exist
if [ ! -f ./.bashrc ]; then
    touch .bashrc
    chmod 755 .bashrc
    echo "#!/bin/bash" >> .bashrc
fi

# Append the customed alias
echo " " >> .bashrc
echo "alias python3='python3.3'" >> .bashrc
echo " " >> .bashrc

# Reload settings in the .bashrc script
source .bashrc

Solution 2

You may run different python versions on the same system by setting up the appropriate environment variables. This would allow you to locally install a later version of Python than the synaptic package manager might offer. e.g. in a file (mysetup) have:

TK_LIBRARY=/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/site-packages/PIL:/usr/lib   
TKPATH=/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/site-packages/PIL:/usr/lib 
TCL_LIBRARY=/usr/lib 
export TCL_LIBRARY TK_LIBRARY TKKPATH   

export PYTHONPATH=/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-stdwin:/usr/lib/python2.7/lib-dynload:/usr/lib:.     

and put them into your environment with . mysetup

Share:
10,024

Related videos on Youtube

user1873947
Author by

user1873947

Updated on September 18, 2022

Comments

  • user1873947
    user1873947 over 1 year

    So, to keep it simple. Ubuntu 12.10 has python 3.2 pre installed and it is linked to "python3". I downloaded python 3.3 and it's command is "python3.3". However, I downloaded pySide for python3 from synaptic. Using "from PySide.QtCore import *" fails on python3.3. BUT, when I ran just "python3" (aka 3.2) everything works fine. Synaptic just installed lib for python3.2 which is default for python3 in ubuntu. How can I force synaptic to install modules for python3.3?

    Thanks

  • user1873947
    user1873947 over 11 years
    Thanks. This will make installing modules from synaptic to python3.3 dir, yes?
  • user1873947
    user1873947 over 11 years
    Well, this indeed makes "python3" run "python3.3", but after installing python3 module from synaptic, it still installs only to python 3.2... There must be some magic with symlinks to 3.3 location.
  • ssb
    ssb about 11 years
    I'm having the same issue, trying to download packages but they default to the wrong installation