Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to upgrade Python 2.6 to 2.7
View unanswered posts
View posts from last 24 hours

Goto page 1, 2, 3  Next  
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Helena
Veteran
Veteran


Joined: 02 Apr 2003
Posts: 1027
Location: De Meern, The Netherlands

PostPosted: Fri Mar 25, 2011 9:45 am    Post subject: How to upgrade Python 2.6 to 2.7 Reply with quote

EDIT revised to quickly display the solution without having to search the entire topic

In the stable tree python 2.7 has been available for some time. However the upgrade from 2.6 needs to be performed in a certain manner.

Immediately after emerging python 2.7 a message is displayed by portage about running python-updater. This message does not list all steps required which are:
Code:
eselect python set python2.7
python-updater
emerge --depclean
revdep-rebuild
NOTE of course the last two lines may affect other packages as well!

Below is the rest of my original post....
  • First: why is it necessary? I always upgrade to the latest version but this one doesn't seem to offer any improvements and does cost a lot of effort (see below).
  • Second: how to perform the upgrade? the ebuild only mentions python-updater but forgets to mention the necessary eselect-command.
  • Third: what happens during the upgrade? I have to rebuild almost 60 packages, a lot of them Gnome-related. On an older Athlon-based system this can take a couple of hours (in fact 160 min...).


Mod Edit: stuck - tomk


Last edited by Helena on Thu Apr 28, 2011 5:01 pm; edited 3 times in total
Back to top
View user's profile Send private message
mikegpitt
Advocate
Advocate


Joined: 22 May 2004
Posts: 3200

PostPosted: Fri Mar 25, 2011 7:28 pm    Post subject: Re: Python 2.7 upgrade? Reply with quote

Helena wrote:
In the stable tree python 2.7 has been available for some time.

I wouldn't really use the term "some time"... it looks like it just went stable yesterday for some archs, and many more are still marked unstable.

Helena wrote:
  • First: why is it necessary? I always upgrade to the latest version but this one doesn't seem to offer any improvements and does cost a lot of effort (see below).
You aren't forced to update python or switch to the new version, but eventually ebuilds will depend on this version. Once it is marked as stable, it will likely be the default for testing, and when that happens, usually the dependencies will reflect the software versions the devs used to test.

Helena wrote:
  • Second: how to perform the upgrade? the ebuild only mentions python-updater but forgets to mention the necessary eselect-command.
  • Usually all you need to do is python-updater... If I remember correctly sometimes the ebuild will handle the eselect. If you want to make sure, run eselect to change to the 2.7 branch then run python-updater.

    Helena wrote:
  • Third: what happens during the upgrade? I have to rebuild almost 60 packages, a lot of them Gnome-related. On an older Athlon-based system this can take a couple of hours (in fact 160 min...).
  • This is necessary and optional all at the same time. I say necessary since it will point your binaries to use the new python version, but optional since the dependencies will continue to work fine pointing to the old python (unless you decide to remove it from your system). Using python-updater should be really simple and automatic for most people... just type the command and sit back.
    Back to top
    View user's profile Send private message
    Anon-E-moose
    Advocate
    Advocate


    Joined: 23 May 2008
    Posts: 2096
    Location: Dallas area

    PostPosted: Fri Mar 25, 2011 7:39 pm    Post subject: Reply with quote

    steps to the upgrade

    1. emerge python
    2. eselect python list
    3. eselect python set <whatever 2.7 is>
    4. python-upgrade (may take awhile, depending on how many pkgs you have that use it - 59 for me)
    5. (optional) emerge --depclean python (to get rid of old python, I always run with -p to see what it will do first)
    _________________
    Asus m5a99fx, FX 8320 - amd64-multilib, 3.9.1-zen, eudev
    glibc-2.17, gcc-4.7.3-r1, xorg-server-1.15, lxde, nouveau, oss4
    Back to top
    View user's profile Send private message
    thumper
    Guru
    Guru


    Joined: 06 Dec 2002
    Posts: 441
    Location: Venice FL

    PostPosted: Fri Mar 25, 2011 7:52 pm    Post subject: Reply with quote

    And it all seems to go sideways, check you make.conf and be sure you don't have this haunting you:
    Code:
    USE_PYTHON="2.6"


    if you do, you can adjust accordingly.

    George
    Back to top
    View user's profile Send private message
    ferreirafm
    Guru
    Guru


    Joined: 28 Jul 2005
    Posts: 446
    Location: Sao Paulo, Brazil

    PostPosted: Fri Mar 25, 2011 8:14 pm    Post subject: Reply with quote

    Hi Helena,
    When updating python the emerge is going to remove the version 2.6. So you need to eselect the new pyhton version just installed.
    Otherwise, I can't be able to run the python-update. Have a look on this thread
    G'Luck
    Back to top
    View user's profile Send private message
    keenblade
    Veteran
    Veteran


    Joined: 03 Oct 2004
    Posts: 1085

    PostPosted: Fri Mar 25, 2011 11:38 pm    Post subject: Reply with quote

    ferreirafm wrote:
    Hi Helena,
    When updating python the emerge is going to remove the version 2.6. ...

    No, portage won't remove v2.6. It wil install v2.7 into another slot. And for me, python-updater needed a patch from g.b.o to perform the update. Because python-updater stopped with an error without updating the list it created. Maybe the patch is already appled. Don't know.
    _________________
    Anyway it's all the same at the end...
    Need help to get it working: "x-fi surround 5.1"
    Back to top
    View user's profile Send private message
    TiccTech
    n00b
    n00b


    Joined: 13 Jun 2004
    Posts: 34
    Location: Oregon, US

    PostPosted: Sat Mar 26, 2011 12:16 am    Post subject: Reply with quote

    Quote:
    No, portage won't remove v2.6. It wil install v2.7 into another slot.

    True. However, if you do then run python-updater as instructed by the ebuild, and then run emerge --depclean as instructed by portage, portage does indeed remove Python 2.6.

    And then anything that uses Python doesn't work. Like portage. The ebuild probably should have said to eselect the new Python version before running python-updater. If you, like me, find yourself in this situation, the fix seems to be to eselect Python 2.7, then run python-updater again and let it rebuild a whole bunch of stuff.

    -TiccTech
    Back to top
    View user's profile Send private message
    Helena
    Veteran
    Veteran


    Joined: 02 Apr 2003
    Posts: 1027
    Location: De Meern, The Netherlands

    PostPosted: Sat Mar 26, 2011 10:12 am    Post subject: Reply with quote

    I would suggest the developers to update the ebuild message to mention the following commands:
    Code:
    eselect python set python2.7
    python-updater
    The other suggestions such as the make.conf USE variable may be relevant to a few users; I didn't know it existed anyway. Also since 2.6 and 2.7 exist in different slots general package maintenance applies; imho this need not be mentioned. A warning that running python-updater is really necessary before removing 2.6 could also be useful; I've been struck by this problem too and portage will stop working if you do.
    Back to top
    View user's profile Send private message
    hujuice
    Apprentice
    Apprentice


    Joined: 16 Oct 2007
    Posts: 198
    Location: Rome, Italy

    PostPosted: Sat Mar 26, 2011 1:23 pm    Post subject: Reply with quote

    What goes wrong is this simple sequence:
    Code:
    #emerge -uND world
    emerge --depclean
    revdep-rebuild

    As told before, the depclean will suggest to remove dev-lang/python:2.6 and, as told, the ebuild messages didn't say anything about (I believe so: am I wrong?).
    Wise people (me 8) ) could think that rising from 2.6 to 2.7 will be painless.

    The correct steps are already mentioned:
    Code:
    #emerge -uND world
    eselect python list
    eselect python set N
    python-updater
    emerge --depclean
    revdep-rebuild

    (N corresponding to 2.7)

    If you fall down in the wrong case, it's easy to repair.
    Code:
    emerge --oneshot dev-lang/python:2.6
    eselect python set N
    python-updater
    emerge --unmerge dev-lang/python:2.6
    revdep-rebuild

    (N corresponding to 2.7)

    I agree: ebuild messages should advise better, with a yellow warning message.

    Regards,
    HUjuice
    _________________
    Who haven't a spine, should have a method.
    Chi non ha carattere, deve pur avere un metodo.
    Back to top
    View user's profile Send private message
    albright
    Advocate
    Advocate


    Joined: 16 Nov 2003
    Posts: 2061
    Location: Near Toronto

    PostPosted: Sat Mar 26, 2011 1:57 pm    Post subject: Reply with quote

    sorry to be so blunt, but I've been bitten before with these
    kind of "upgrades"

    I have *three* versions of python on my sytem at the
    moment, all marked stable: 2.6, 2.7 and 3.1

    I'd like to have just one (just for the sake of "elegance"
    and simplicity).

    Is it perfectly safe to eselect python X (which X?) and
    run python-updater and trash the other two versions
    of python?

    Thanks for any advice.
    _________________
    .... there is nothing - absolutely nothing - half so much worth
    doing as simply messing about with Linux ...
    (apologies to Kenneth Graeme)
    Back to top
    View user's profile Send private message
    hujuice
    Apprentice
    Apprentice


    Joined: 16 Oct 2007
    Posts: 198
    Location: Rome, Italy

    PostPosted: Sat Mar 26, 2011 2:21 pm    Post subject: Reply with quote

    I've three version too.
    Code:
    # eselect python list
    Available Python interpreters:
      [1]   python2.6
      [2]   python2.7 *
      [3]   python3.1

    I believe that your case is similar.

    You can select the "active" one by your choice:
    Code:
    eselect python set X

    where X is the number listed before.

    In my case:
    Code:
    # eselect python set 2

    For python 2.7 (it's already done, so the star).
    This is the usual eselect Gentoo gymnastics (try 'eselect modules list').

    About the three versions... the answer is here:
    Code:
    # equery depends dev-lang/python:2.6
    # equery depends dev-lang/python:2.7
    # equery depends dev-lang/python:3.1

    where each command will show the dependencies.

    I'm pretty "sure" (never by dogma 8O , equery knows...) that you can remove the 2.6 version, after the python-updater task.
    (I'm python-updating right now.)

    Regards,
    HUjuice
    _________________
    Who haven't a spine, should have a method.
    Chi non ha carattere, deve pur avere un metodo.
    Back to top
    View user's profile Send private message
    mikegpitt
    Advocate
    Advocate


    Joined: 22 May 2004
    Posts: 3200

    PostPosted: Sat Mar 26, 2011 3:23 pm    Post subject: Reply with quote

    Python 2.6 can probably go after the update to 2.7, but you should verify that there are no ebuilds depending on 2.6 (with equery or depclean) before you remove it... and after you've done a python-updater.

    You should have at least one 2.x branch and one 3.x branch right now. Don't use eselect to migrate to the 3.x branch, since a lot of tools (like portage) still want 2.x.
    Back to top
    View user's profile Send private message
    Dont Panic
    Guru
    Guru


    Joined: 20 Jun 2007
    Posts: 320
    Location: SouthEast U.S.A.

    PostPosted: Sat Mar 26, 2011 7:59 pm    Post subject: Reply with quote

    Is it mandatory now to have a USE_PYTHON="2.7" line in your make.conf?

    I've been having troubles working through the upgrade to python:2.7. Something keeps reverting my selected python version back to python:2.6. I thought I was going crazy at first, but I reviewed my bash history just to make sure I didn't accidentally do it myself.

    I also have a few packages that are installing to python:2.6 even when python:2.7 is correctly eselected (such as app-emulation/emul-linux-x86-baselibs and sys-libs/tdb).
    Back to top
    View user's profile Send private message
    Helena
    Veteran
    Veteran


    Joined: 02 Apr 2003
    Posts: 1027
    Location: De Meern, The Netherlands

    PostPosted: Sat Mar 26, 2011 9:04 pm    Post subject: Reply with quote

    Dont Panic wrote:
    Is it mandatory now to have a USE_PYTHON="2.7" line in your make.conf?
    I never used this variable and in my opinion it is necessary at all, so my advice is to leave it out completely. I found a relevant (gentoo dev's?) blog:
    Quote:
    When installing [...] with no USE_PYTHON line in /etc/make.conf by default you will get files for the active version of Python 2.x and Python 3.x.
    Also you need only one 2.x python version
    mikegpitt wrote:
    Python 2.6 can probably go after the update to 2.7, but you should verify that there are no ebuilds depending on 2.6 (with equery or depclean) before you remove it... and after you've done a python-updater.
    Correct, I performed the cleaning steps as described before (emerge --depclean && revdep-rebuild) but only after the 2.7 upgrade steps shown earlier, and python2.6 is gracefully removed.
    hujuice wrote:
    About the three versions... the answer is here:
    Code:
    # equery depends dev-lang/python:2.6
    # equery depends dev-lang/python:2.7
    # equery depends dev-lang/python:3.1

    where each command will show the dependencies.
    A new but possibly interesting feature of gentoolkit, however its output is a little hard to interpret. I also would expect python-updater to take care of everything without me having to check further!

    So, to summarize, the only steps needed are, to my best belief
    Code:
    eselect python set python2.7
    python-updater
    emerge --depclean
    revdep-rebuild
    Note: this remains true as long as we need to keep both a 2.x and a 3.x Python version active. This was already mentioned in an "eselect news" item if I remember well when python 3 first became available.
    Back to top
    View user's profile Send private message
    hujuice
    Apprentice
    Apprentice


    Joined: 16 Oct 2007
    Posts: 198
    Location: Rome, Italy

    PostPosted: Sat Mar 26, 2011 9:30 pm    Post subject: Reply with quote

    Quote:
    Note: this remains true as long as we need to keep both a 2.x and a 3.x Python version active. This was already mentioned in an "eselect news" item if I remember well when python 3 first became available.

    It's so.

    About equery
    Quote:
    A new but possibly interesting feature of gentoolkit, however its output is a little hard to interpret.

    A good way to interpret the output is to take a look here: http://www.gentoo.org/proj/en/Python/developersguide.xml#doc_chap2
    I'm not very skilled in this filed, but it is enough clear there.

    I love Gentoo Linux because it is one of the best opensource logic, where knowledge is shared as well as code is.
    The prize is that we need to understand. Always... 8)

    Regards,
    HUjuice
    _________________
    Who haven't a spine, should have a method.
    Chi non ha carattere, deve pur avere un metodo.
    Back to top
    View user's profile Send private message
    jordanwb
    l33t
    l33t


    Joined: 10 Jul 2008
    Posts: 642
    Location: Ottawa, Canada

    PostPosted: Sat Mar 26, 2011 10:01 pm    Post subject: Reply with quote

    If you use eog (Gnome's image viewer) or layman, you'll have to recompile them, I did at least.
    Back to top
    View user's profile Send private message
    cwr
    Veteran
    Veteran


    Joined: 17 Dec 2005
    Posts: 1632

    PostPosted: Sun Mar 27, 2011 2:22 pm    Post subject: Reply with quote

    Are there in fact any packages which depend on Python 3.0? I suppose there
    will be in the end, but at present?

    I've actually masked the Python 3x builds, and simply run Python 2.6, and
    everything seems to work. I'll update to 2.7, and probably leave things there
    until Portage is 3.0 capable.

    Will
    Back to top
    View user's profile Send private message
    Anon-E-moose
    Advocate
    Advocate


    Joined: 23 May 2008
    Posts: 2096
    Location: Dallas area

    PostPosted: Sun Mar 27, 2011 2:25 pm    Post subject: Reply with quote

    cwr wrote:
    Are there in fact any packages which depend on Python 3.0? I suppose there
    will be in the end, but at present?

    I've actually masked the Python 3x builds, and simply run Python 2.6, and
    everything seems to work. I'll update to 2.7, and probably leave things there
    until Portage is 3.0 capable.

    Will


    I've had 3.* masked for a while and have not had anything demand that I have it installed.
    When something does need it to compile/emerge then I'll revisit my masking.
    _________________
    Asus m5a99fx, FX 8320 - amd64-multilib, 3.9.1-zen, eudev
    glibc-2.17, gcc-4.7.3-r1, xorg-server-1.15, lxde, nouveau, oss4
    Back to top
    View user's profile Send private message
    hujuice
    Apprentice
    Apprentice


    Joined: 16 Oct 2007
    Posts: 198
    Location: Rome, Italy

    PostPosted: Sun Mar 27, 2011 2:45 pm    Post subject: Reply with quote

    cwr wrote:
    Are there in fact any packages which depend on Python 3.0? I suppose there
    will be in the end, but at present?

    I've actually masked the Python 3x builds, and simply run Python 2.6, and
    everything seems to work. I'll update to 2.7, and probably leave things there
    until Portage is 3.0 capable.

    Will


    Python 3.x is simply the last stable version of Python.
    So, the portage (rightly, IMHO) cannot decide «ehy folks, you don't need it, I'll mask it for you». Even if it is still rarely needed...

    The slotted solution is the right solution for the "portage point of view", while masking Python 3.x is a user solution that make sense if you don't need it.

    Regards,
    HUjuice
    _________________
    Who haven't a spine, should have a method.
    Chi non ha carattere, deve pur avere un metodo.
    Back to top
    View user's profile Send private message
    figueroa
    Apprentice
    Apprentice


    Joined: 14 Aug 2005
    Posts: 219
    Location: GA-USA

    PostPosted: Wed Apr 20, 2011 1:14 am    Post subject: Upgrading to python-2.7 safely Reply with quote

    python-2.7.1-r1 x86 became stable today. I ran emerge -uDN world and upon checking /var/log/portage/elog entries, I found:
    Quote:
    You have just upgraded from an older version of Python.
    You should run 'python-updater ${options}' to rebuild Python modules.

    This is very incomplete. Other recent threads on updating python show the necessary steps, but not completely or at least not safely. Here is what I think should be done to update to the current python 2 while avoiding disaster.

    1. After "emerge -uDN world" check for messages in /var/log/portage/elog (python update assumed)
    2. run "revdep-rebuild -i -p" and if nothing required, fine, or if the results look sane, run "revdep-rebuild" to fix dependency problems.
    3. Then, run "eselect python list" to check versions.
    4. If list just shows:
    Quote:
    Available Python interpreters:
    [1] python2.6 *
    [2] python2.7

    run "eselect python set 2"
    5. Then run "python-updater"
    6. After that run "emerge --depclean -p" and carefully screen the list for sanity. If in doubt about the proposed removals, double check with "equery d programname" or other tools. Your old python will probably be on the list. Before you let it be deleted, run "equery d python" looking for any version depclean proposes to delete. I found many of my installed packages still needing python-2.6 including portage. Prevent depclean from removing python-2.6 by running "emerge --noreplace =python-2.6.6-r2"
    7. Rerun "emerge -udN world" and "revdep-rebuild" to correct any anomalies.

    As a side note, I currently have python 3 masked, since nothing I use requires it.

    Feel free to add to this thread.

    Added by self:
    Question - Why does running "equery d =python-2.6.6-r2" and "equery d =python-2.7.1-r1" return exactly the same package list, except with the first many indicate they need 2.6 and with the second many indicate that they need 2.7? Perhaps nothing actually needs python 2.6?
    Is it really safe to let emerge --depclean remove python-2.6.6-r2 after following my instructions above?
    _________________
    Andy Figueroa
    andy@andyfigueroa.us
    Back to top
    View user's profile Send private message
    tomk
    Administrator
    Administrator


    Joined: 23 Sep 2003
    Posts: 7219
    Location: Sat in front of my computer

    PostPosted: Wed Apr 20, 2011 8:43 am    Post subject: Reply with quote

    Merged previous post and made this one sticky.
    _________________
    Search | Read | Answer | Report | Strip
    Back to top
    View user's profile Send private message
    AgBr
    Apprentice
    Apprentice


    Joined: 06 Nov 2010
    Posts: 170

    PostPosted: Thu Apr 21, 2011 2:25 pm    Post subject: Python 2 vs Python 3 Reply with quote

    I am in the process of installing a new notebook from stage3. I just noticed that latest stage3/portage selected python 3.1 as active. My impression from this thread is, that 2.7 just became stable. So why does latest stage3/portage make 3.1 active?
    Back to top
    View user's profile Send private message
    mikegpitt
    Advocate
    Advocate


    Joined: 22 May 2004
    Posts: 3200

    PostPosted: Thu Apr 21, 2011 4:25 pm    Post subject: Re: Python 2 vs Python 3 Reply with quote

    AgBr wrote:
    I am in the process of installing a new notebook from stage3. I just noticed that latest stage3/portage selected python 3.1 as active. My impression from this thread is, that 2.7 just became stable. So why does latest stage3/portage make 3.1 active?
    Portage 2.7 and 3.1 are in different slots, meaning you can have both installed at the same time. Unless something has changed, it is still recommended to keep 2.7 as the system python. If the latest livecd's are going with 3.1, then this could be an update and 3.1 will become recommended... or a mistake.

    Interestingly on my system even though python-2.7 is marked stable, it hasn't been pulled in from any recent merges. Perhaps this is because no packages on my system require this version explicitly.
    Back to top
    View user's profile Send private message
    Longsight
    n00b
    n00b


    Joined: 23 Apr 2011
    Posts: 3

    PostPosted: Sat Apr 23, 2011 11:04 pm    Post subject: Reply with quote

    A note on python-updater: if you notice it seems to hang for quite some time around the sys- categories, fear not - it's probably checking whatever kernel sources you have installed. This can take a very flippin' long time. It really ought to be possible to tell it to skip certain packages or categories, as there really is never going to be a need for it to check *-sources, and doing so can take what seems like an eternity on slower machines, especially if you've got a lot of old sources kicking about.
    Back to top
    View user's profile Send private message
    hamilito
    n00b
    n00b


    Joined: 18 Aug 2010
    Posts: 33

    PostPosted: Wed Apr 27, 2011 4:00 pm    Post subject: Reply with quote

    This is an issue I had after upgrading (emerged world which automatically upgraded python from 2.7 to 3.1). Thread:can't emerge anything just in case people reading this post get the same error I got. Maybe it'll help.
    Back to top
    View user's profile Send private message
    Display posts from previous:   
    Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
    Goto page 1, 2, 3  Next
    Page 1 of 3

     
    Jump to:  
    You cannot post new topics in this forum
    You cannot reply to topics in this forum
    You cannot edit your posts in this forum
    You cannot delete your posts in this forum
    You cannot vote in polls in this forum