Find the answer to your Linux question:
Results 1 to 5 of 5
Hello again all. Thanks for your help over the months! I recently migrated to Python 3, and my distro (Mint 14) comes with it as well as Python 2.7. Apt-get ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2013
    Posts
    19

    Configuring/Updating Python


    Hello again all. Thanks for your help over the months!

    I recently migrated to Python 3, and my distro (Mint 14) comes with it as well as Python 2.7.

    Apt-get only pulls out Python 3.2.3, but the latest version is 3.3.1. All of the guides I could find only mentioned how to install Python 3 to begin with, but I want to update it.

    Also, I'm pretty hazy about how Linux generally handles command-line statements for programs:

    For Python 3, I use python3
    For Python 2, I use python.

    I always use Python 3 by default; can I change it to:

    python for Python 3
    python2 for Python 2

    Is this simply a matter of renaming directories in /bin? I don't want to wreck my distro messing around in there without knowing for sure.

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,225
    The simplest way to handle this sort of problem is to create an alias. Find out what the actual programs are called and write a line alias preferred_name=actual_name into the .bashrc file in your home directory. Bash always interprets aliases before looking for commands so you should be all right. Alternatively you could put in symbolic links with your desired names and make them point to the actual programs. Renaming commands is not a good idea as there are always scripts and programs that depend on them.
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  3. #3
    Just Joined!
    Join Date
    Feb 2013
    Posts
    19
    Good point, I didn't actually consider that carefully enough. I don't want to break my top-level file after distribution...

    What about a pain-free way of updating to a more recent 3.x?

  4. #4
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,225
    Quote Originally Posted by deuteros View Post
    What about a pain-free way of updating to a more recent 3.x?
    If it isn't in the repository, the only way I can think of to get it is to download source code and build it locally. I don't know if that qualifies as pain-free in your eyes, but it certainly isn't too difficult.

    Basically you first need to install the "build-essential" package from the Mint repo, then download the source tarball (a .tar.gz or .tar.bz2 or .tar.xz package) from the python site. Unpack it, read the README and INSTALL files carefully, then do as they tell you.
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  5. #5
    Just Joined!
    Join Date
    Feb 2013
    Posts
    19
    I installed it from source last time, but it failed for some unknown reason. Now that I installed build-essential, it worked. Unfortunately, the default version for command "python3" was still 3.2.3.

    I messed around a bit, and for some strange reason, python3 now gives me python 3.3.1, which is what I wanted.

    I guess it worked. I hope I didn't hurt something.....

    EDIT: Turns out my distro doesn't come with a .bashrc file I guess, so I made a file called ".bashrc" with a bash hashbang (say that three times fast) and wrote:

    Code:
    alias python=python3
    It didn't work at first, but I restarted the terminal and then it worked swimmingly.

    Now I won't be kept up at nights worrying anymore. Thank you for saving the day, Whistler's Mother!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •