Newbie: where's the new python gone?

Discussion in 'Python' started by BobAalsma, Sep 9, 2012.

  1. BobAalsma

    BobAalsma Guest

    I think I've installed Python 2.7.3 according to the instructions in the README, and now want to use that version.
    However, when typing "python" in Terminal, I get "Python 2.6.4 (r264:75821M, Oct 27 2009, 19:48:32) ".
    So:
    (1) I can't seem to find where the new software has gone and
    (2) can't seem to find how to point to this new versoin.
    I've searched Python.org and with Google but :(
    [I'm on Mac OS X 10.7.4]

    Please help.
    BobAalsma, Sep 9, 2012
    #1
    1. Advertising

  2. On Sun, 09 Sep 2012 07:28:55 -0700, BobAalsma wrote:

    > I think I've installed Python 2.7.3 according to the instructions in the
    > README, and now want to use that version. However, when typing "python"
    > in Terminal, I get "Python 2.6.4 (r264:75821M, Oct 27 2009, 19:48:32) ".


    Did you run "make altinstall"? You should, because it is a bad idea to
    replace the system Python with a newer (or worse, older) version. You can
    break things.


    > So:
    > (1) I can't seem to find where the new software has gone


    Just enter "python2.7" instead of "python" and it should work perfectly.


    > and (2) can't
    > seem to find how to point to this new versoin. I've searched Python.org


    You won't find it there *wink*

    At the terminal, enter:

    which python2.7

    which should return the full path to the executable, e.g.:

    [steve@ando ~]$ which python2.7
    /usr/local/bin/python2.7

    My system uses Python 2.4 as the system Python, but I prefer to use
    Python 2.7 as my default. So I have this command in my .bashrc file:

    alias python='python2.7'

    which means that *for me*, "python" launches Python 2.7, but when system
    tools call "python" they still see the version they are expecting.

    If your shell is something other than bash, you may need to use a
    different rc file.

    Did any of this make sense to you? If anything was unclear, please don't
    hesitate to ask.



    --
    Steven
    Steven D'Aprano, Sep 9, 2012
    #2
    1. Advertising

  3. BobAalsma

    BobAalsma Guest

    Op zondag 9 september 2012 16:28:55 UTC+2 schreef BobAalsma het volgende:
    > I think I've installed Python 2.7.3 according to the instructions in the README, and now want to use that version.
    >
    > However, when typing "python" in Terminal, I get "Python 2.6.4 (r264:75821M, Oct 27 2009, 19:48:32) ".
    >
    > So:
    >
    > (1) I can't seem to find where the new software has gone and
    >
    > (2) can't seem to find how to point to this new versoin.
    >
    > I've searched Python.org and with Google but :(
    >
    > [I'm on Mac OS X 10.7.4]
    >
    >
    >
    > Please help.


    Thanks Steven!

    Most of what you wrote made very good sense, yes.

    Umm, I didn't usa altinstall - should I (and can I) go back? [In hindsight I do like your solution to the versopns a lot more, yes]

    Umm2, as said, I think I've installed (at least downloaded) 2.7.3 (note the three there) and with "python2.7" I now see "Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05)"
    BobAalsma, Sep 9, 2012
    #3
  4. BobAalsma

    Ned Deily Guest

    In article <>,
    BobAalsma <> wrote:
    > Umm2, as said, I think I've installed (at least downloaded) 2.7.3 (note the
    > three there) and with "python2.7" I now see "Python 2.7.1 (r271:86832, Jun 16
    > 2011, 16:59:05)"


    Did you use a binary installer from python.org or did you build it
    yourself from source? In the former case, you should find the newer
    python2.7 at /usr/local/bin/python2.7. Also, the installer by default
    should have added the framework bin directory to your shell PATH. Try
    opening a new terminal window and typing python2.7. In any case, as
    suggested:

    which python

    should tell you the path to the python you are invoking. It doesn't
    appear to be an Apple-supplied one or a python.org one, BTW.

    --
    Ned Deily,
    Ned Deily, Sep 9, 2012
    #4
  5. BobAalsma

    Hans Mulder Guest

    On 9/09/12 16:28:55, BobAalsma wrote:
    > I think I've installed Python 2.7.3 according to the instructions in the README, and now want to use that version.
    > However, when typing "python" in Terminal, I get "Python 2.6.4 (r264:75821M, Oct 27 2009, 19:48:32) ".


    Was that a freshly opened Terminal window, or one that was open
    before the install?

    The installers from python.org by default modify
    your .bashrc file to put
    /Library/Frameworks/Python.framework/Versions/2.7/bin
    at the front of your shell's search path.

    However, that only affects windows opened after the install
    (unless you use "source ~/.bashrc" to read the new setting
    into a pre-existing window).

    What happens if you type:
    /Library/Frameworks/Python.framework/Versions/2.7/bin/python ?

    > So:
    > (1) I can't seem to find where the new software has gone and
    > (2) can't seem to find how to point to this new versoin.
    > I've searched Python.org and with Google but :(
    > [I'm on Mac OS X 10.7.4]


    I'm on MacOS 10.5.0, and my default Python is
    /Library/Frameworks/Python.framework/Versions/2.7/bin/python

    If yours isn't, you could try looking in finder at the
    disk you installed Python to, and see if it has a top-level
    folder named "Library", containing "Frameworks", etc.

    If you find a "Python.framework" under /System/Library
    that's the one that ships with MacOS.

    Hope this helps,

    -- HansM
    Hans Mulder, Sep 9, 2012
    #5
  6. On 10/09/2012 07:10, Dwight Hutto wrote:
    > I have several installations on my windows, so I use
    > c:\python27_64\python.exe module_file.py
    >
    > or
    >
    > c:\python26\python.exe module_file.py
    >
    > in the command line.
    >
    >
    > Not to show that this shouldn't be a discussion, but usually it's
    > searching. Here's search term a link, and some python docs:
    >
    > install python windows command line
    >
    > or click:
    >
    > https://www.google.com/search?q=ins...mozilla:en-US:official&client=firefox-ahere's
    >
    > and one of the better results:
    >
    > http://docs.python.org/faq/windows.html#how-do-i-run-a-python-program-under-windows
    >
    >
    >
    >


    Why have you posted this seeing that the OP stated that they're on Mac OS X?

    The windows faq is outdated wrt PEP397. An up to date version is
    available here http://docs.python.org/dev/using/windows.html

    --
    Cheers.

    Mark Lawrence.
    Mark Lawrence, Sep 10, 2012
    #6
  7. On Sun, Sep 9, 2012 at 11:10 PM, Dwight Hutto <> wrote:
    >
    > I have several installations on my windows, so I use
    > c:\python27_64\python.exe module_file.py
    >
    > or
    >
    > c:\python26\python.exe module_file.py
    >
    > in the command line.
    >
    >
    > Not to show that this shouldn't be a discussion, but usually it's searching.
    > Here's search term a link, and some python docs:
    >
    > install python windows command line
    >
    > or click:
    >
    > https://www.google.com/search?q=ins...mozilla:en-US:official&client=firefox-ahere's
    >
    > and one of the better results:
    >
    > http://docs.python.org/faq/windows.html#how-do-i-run-a-python-program-under-windows
    >
    >
    > --
    > Best Regards,
    > David Hutto
    > CEO: http://www.hitwebdevelopment.com
    >


    The problem is related to Python on Mac, not on Windows. As was stated
    in the original post.
    Benjamin Kaplan, Sep 10, 2012
    #7
  8. BobAalsma

    Hans Mulder Guest

    On 10/09/12 15:04:24, William R. Wing (Bill Wing) wrote:
    > On Sep 9, 2012, at 10:28 AM, BobAalsma <> wrote:
    >
    >> I think I've installed Python 2.7.3 according to the instructions in the README, and now want to use that version.
    >> However, when typing "python" in Terminal, I get "Python 2.6.4 (r264:75821M, Oct 27 2009, 19:48:32) ".
    >> So:
    >> (1) I can't seem to find where the new software has gone and
    >> (2) can't seem to find how to point to this new versoin.
    >> I've searched Python.org and with Google but :(
    >> [I'm on Mac OS X 10.7.4]
    >>
    >> Please help.
    >> --
    >> http://mail.python.org/mailman/listinfo/python-list

    >
    > Bob, I'm coming into this late, but it doesn't appear that you've

    < gotten a satisfactory answer yet. Let's take it one step at a time.
    >
    > First, if none of the hints you've received earlier have gotten you going.
    > Maybe the thing is to resort to a bigger hammer. In a terminal window:
    >
    > $sudo find / -name Python -print<return>
    >
    > This will search the entire file system for all the files named Python


    Trouble is, the file you're looking for is named "python" and this
    command is case-sensitive. So the command you need would be:

    sudo find / -name python -print


    > and will ask for your admin password so it can search in directories
    > owned by root.


    The file you're looking for is in a directory that you can read
    with more mundane permissions, so you might want to leave off
    the "sudo" prefix. If you do, you'll get some message about
    permission problems.


    > (It may also generate quite a bit of output, so you might want
    > to capture it in a file.)


    For example:

    find / -name python > /tmp/pythons.txt 2> /dev/null

    The 2>/dev/null bit throws away warnings about permission problems
    and the like.

    Alternatively, you can cut down the output like so:

    find / -name python -print | grep bin/python

    That will only report pythons found in directories named "bin".
    On my laptop, that cuts the output down to:

    /Library/Frameworks/Python.framework/Versions/2.7/bin/python
    /opt/local/bin/python
    /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python
    /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python
    /System/Library/Frameworks/Python.framework/Versions/2.5/bin/python
    /System/Library/Frameworks/Python.framework/Versions/2.6/bin/python
    /usr/bin/python
    /usr/local/bin/python

    Those are all valid python interpreters, or wrappers for same.

    > In any case, this will take several minutes and while it is running,
    > you can be checking a couple of other things. OS X doesn't use a
    > .bashrc file by default (you can make it do so if you want, but
    > that's extra work right now). It uses .login and then .profile
    > to set up your python path _if_ you've used the installer from python.org.


    I doubt it. What files are used, depends on which shell you use.
    Bash uses .profile; the C shell uses .login and .cshrc.

    I don't think there is a shell that can read both .login and .profile
    since .login typically uses C shell syntax and .profile uses Bourne
    shell syntax.

    If you're not sure which shell you have, type

    echo $SHELL

    at the shell prompt.

    > So, look to see if you have a .profile in your ~ directory. If so,
    > then you're using (or have used at some point in the past) an installer
    > from python.org.
    > It should have an entry that looks something like the following:
    >
    > # Setting PATH for Python 2.7
    > # The original version is saved in .profile.pysave
    > PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
    > export PATH
    >
    > Note the distinction between this path and the one from Apple.
    > The python that ships from Apple is in /System/Library/Frameworks…
    >
    > Do NOT touch the one from Apple. Apple uses it for some of its
    > housekeeping operations and you want it to stay just as Apple
    > installed it.


    +1

    > When you finally find the Python 2.7 in the output from the "find"
    > command, you can edit your .login (if you don't have a .profile) or
    > edit .profile if you do.


    Hope this helps,

    -- HansM
    Hans Mulder, Sep 10, 2012
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Abrahams

    PEPs link gone from the Python homepage?

    David Abrahams, Sep 26, 2003, in forum: Python
    Replies:
    11
    Views:
    472
    Skip Montanaro
    Sep 26, 2003
  2. Bernard Lebel

    [python 3.0] reload() gone?

    Bernard Lebel, Aug 31, 2007, in forum: Python
    Replies:
    2
    Views:
    533
    Chris Mellon
    Aug 31, 2007
  3. Replies:
    6
    Views:
    314
    Marco Mariani
    May 13, 2008
  4. RossGK
    Replies:
    2
    Views:
    380
    RossGK
    May 28, 2008
  5. David Combs
    Replies:
    5
    Views:
    262
    David Combs
    Dec 11, 2012
Loading...

Share This Page