python on Mac

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas Nelson

    #1

    python on Mac

    I just purchased a new macbook (os 10.4.6), and I'm trying to install
    python 2.4 on it. I downloaded and ran the two installers recommended
    at http://www.python.org/download/mac/. Now I have IDLE, which runs
    2.4.1, but typing "python" at a terminal still opens 2.3.5, because it
    points to /usr/bin/python. Is there a way to run python 2.4 without
    idle? If I want to do a unix style script, something like
    #!/usr/bin/python
    print "hello world"
    what can I put on the first line that will cause python 2.4 to
    interpret my code?

    Thanks a lot.
    THN

  • James Stroud

    #2
    Re: python on Mac

    Thomas Nelson wrote:[color=blue]
    > I just purchased a new macbook (os 10.4.6), and I'm trying to install
    > python 2.4 on it. I downloaded and ran the two installers recommended
    > at http://www.python.org/download/mac/. Now I have IDLE, which runs
    > 2.4.1, but typing "python" at a terminal still opens 2.3.5, because it
    > points to /usr/bin/python. Is there a way to run python 2.4 without
    > idle? If I want to do a unix style script, something like
    > #!/usr/bin/python
    > print "hello world"
    > what can I put on the first line that will cause python 2.4 to
    > interpret my code?
    >
    > Thanks a lot.
    > THN
    >[/color]

    The python in /usr/bin is a link (to a link). You can do this:

    sudo rm /usr/bin/python
    sudo ln -s \
    /System/Library/Frameworks/Python.framewor k/Versions/2.4/bin/python \
    /usr/bin/python


    This stupid firebird editor word-wraps (and I don't know how to turn
    this completely annoying behavior off. Appearantly this is because it is
    impossible to soft wrap text on the reader side, annoying NNTP veterans
    everywhere--we just can't count on this hard to program behavior in most
    mail readers because its so impossible to program for. Its been this way
    since reader-client word wrapping was predicted to exist at MIT in the
    1970's.) so get a unix guru to help you with that last command if you
    really don't know what's going on.

    James

    --
    James Stroud
    UCLA-DOE Institute for Genomics and Proteomics
    Box 951570
    Los Angeles, CA 90095


    Comment

    • Thomas Nelson

      #3
      Re: python on Mac

      There is no 2.4 in my Versions folder, only 2.3 and current. Should
      one of the installers have created this directory? Which one?

      THN

      Comment

      • Alex Martelli

        #4
        Re: python on Mac

        Thomas Nelson <thn@mail.utexa s.edu> wrote:
        ...[color=blue]
        > at http://www.python.org/download/mac/. Now I have IDLE, which runs[/color]

        Darn, that page needs to be fixed -- it's out of date!-( Sorry...

        See instead <http://www.python.org/download/releases/2.4.3/> and
        download
        <http://www.python.org/ftp/python/2.4.3/Universal-MacPython-2.4.3.dmg>,
        you should be much happier.


        Alex

        Comment

        • Thomas Nelson

          #5
          Re: python on Mac

          Thanks to you both. I downloaded the dmg suggested, and trustingly
          typed:
          sudo rm /usr/bin/python
          sudo ln -s /usr/local/bin/python2.4 /usr/bin/python
          And now my command line and scripts behave the way I expect. Thanks
          again.

          THN

          Comment

          • pierreth

            #6
            Re: python on Mac

            You removed /usr/bin/python! This is a really bad idea. You should
            never modify /usr/bin because the system is expecting it. This is why
            the new installation is in /usr/local/bin.

            Modify your /usr/local instead are change your .login file instead. It
            is much safer.

            Comment

            • Robert Kern

              #7
              Re: python on Mac

              James Stroud wrote:[color=blue]
              > Thomas Nelson wrote:
              >[color=green]
              >>I just purchased a new macbook (os 10.4.6), and I'm trying to install
              >>python 2.4 on it. I downloaded and ran the two installers recommended
              >>at http://www.python.org/download/mac/. Now I have IDLE, which runs
              >>2.4.1, but typing "python" at a terminal still opens 2.3.5, because it
              >>points to /usr/bin/python. Is there a way to run python 2.4 without
              >>idle? If I want to do a unix style script, something like
              >>#!/usr/bin/python
              >>print "hello world"
              >>what can I put on the first line that will cause python 2.4 to
              >>interpret my code?
              >>
              >>Thanks a lot.
              >>THN[/color]
              >
              > The python in /usr/bin is a link (to a link). You can do this:
              >
              > sudo rm /usr/bin/python
              > sudo ln -s \
              > /System/Library/Frameworks/Python.framewor k/Versions/2.4/bin/python \
              > /usr/bin/python[/color]

              No, for the love of all that is holy, don't do that! OS X depends on stuff in
              /usr/bin/. Don't pull the carpet out from under your OS!

              The python executables from the Python 2.4 installer are installed to
              /usr/local/bin/. I believe that the Universal binary that Alex linked to takes
              care of adjusting the PATH environment variable such that this is exposed.

              --
              Robert Kern
              robert.kern@gma il.com

              "I have come to believe that the whole world is an enigma, a harmless enigma
              that is made terrible by our own mad attempt to interpret it as though it had
              an underlying truth."
              -- Umberto Eco

              Comment

              • Robert Kern

                #8
                Re: python on Mac

                Robert Kern wrote:[color=blue]
                > James Stroud wrote:[/color]
                [color=blue][color=green]
                >>The python in /usr/bin is a link (to a link). You can do this:
                >>
                >>sudo rm /usr/bin/python
                >>sudo ln -s \
                >> /System/Library/Frameworks/Python.framewor k/Versions/2.4/bin/python \
                >> /usr/bin/python[/color]
                >
                > No, for the love of all that is holy, don't do that! OS X depends on stuff in
                > /usr/bin/. Don't pull the carpet out from under your OS![/color]

                C.f.:

                "FAQ 5.7 Describe Apple's Framework implementation of Python and how that
                affects me adding new Python implementations "




                --
                Robert Kern
                robert.kern@gma il.com

                "I have come to believe that the whole world is an enigma, a harmless enigma
                that is made terrible by our own mad attempt to interpret it as though it had
                an underlying truth."
                -- Umberto Eco

                Comment

                • Lou Pecora

                  #9
                  Re: python on Mac

                  In article <e11ou7$git$1@d aisy.noc.ucla.e du>,
                  James Stroud <jstroud@ucla.e du> wrote:
                  [color=blue]
                  > Thomas Nelson wrote:[color=green]
                  > > I just purchased a new macbook (os 10.4.6), and I'm trying to install
                  > > python 2.4 on it. I downloaded and ran the two installers recommended
                  > > at http://www.python.org/download/mac/. Now I have IDLE, which runs
                  > > 2.4.1, but typing "python" at a terminal still opens 2.3.5, because it
                  > > points to /usr/bin/python. Is there a way to run python 2.4 without
                  > > idle? If I want to do a unix style script, something like
                  > > #!/usr/bin/python
                  > > print "hello world"
                  > > what can I put on the first line that will cause python 2.4 to
                  > > interpret my code?
                  > >
                  > > Thanks a lot.
                  > > THN
                  > >[/color]
                  >
                  > The python in /usr/bin is a link (to a link). You can do this:
                  >
                  > sudo rm /usr/bin/python
                  > sudo ln -s \
                  > /System/Library/Frameworks/Python.framewor k/Versions/2.4/bin/python \
                  > /usr/bin/python[/color]

                  YIKES! Don't do that. Don't mess with Apple's python. Not
                  recommended. Check the MacPython FAQ and Wiki pages. Python 2.4 was
                  installed in /usr/local/bin. You should put that in your $PATH variable
                  Before /usr/bin. That will cause the new Python to be launched.

                  -- Lou Pecora (my views are my own) REMOVE THIS to email me.

                  Comment

                  • gene tani

                    #10
                    Re: python on Mac


                    Lou Pecora wrote:[color=blue]
                    > YIKES! Don't do that. Don't mess with Apple's python. Not
                    > recommended. Check the MacPython FAQ and Wiki pages. Python 2.4 was
                    > installed in /usr/local/bin. You should put that in your $PATH variable
                    > Before /usr/bin. That will cause the new Python to be launched.
                    >[/color]

                    some afterthoughts:

                    - look at Oreilly's "OS X Tiger for Unix Geeks" before you do anything
                    that'll break OS X. Just in case you get the idea to upgrade the perl
                    that OS X installed, don't remove the one in /usr/bin either.

                    - investigate the Activestate disk image for OS X/Intel. I say
                    "investigat e" cause i don't have any experience with OS X/Intel, but
                    the Activestate releases i've used for Windows and OS X in the past
                    have all been very high quality.

                    Comment

                    • Thomas Nelson

                      #11
                      Re: python on Mac

                      Well, as I stated in post, I've already replaced the link at
                      /usr/bin/python. I'm not clear why that's unhealthy. Should I change
                      it back to whatever it was before? I guess maybe it was
                      /System/Library/Frameworks/Python.framewor k/Versions/Current/bin/python
                      ?
                      Thanks,
                      THN

                      Comment

                      • Robert Kern

                        #12
                        Re: python on Mac

                        Thomas Nelson wrote:[color=blue]
                        > Well, as I stated in post, I've already replaced the link at
                        > /usr/bin/python. I'm not clear why that's unhealthy.[/color]

                        The FAQ describes why it's unhealthy in detail.

                        "FAQ 5.7 Describe Apple's Framework implementation of Python and how that
                        affects me adding new Python implementations "


                        [color=blue]
                        > Should I change
                        > it back to whatever it was before? I guess maybe it was
                        > /System/Library/Frameworks/Python.framewor k/Versions/Current/bin/python
                        > ?[/color]

                        [src]$ ls -l /usr/bin/python
                        lrwxr-xr-x 1 root wheel 9 May 1 2005 /usr/bin/python -> python2.3
                        [src]$ ls -l /usr/bin/python2.3
                        lrwxr-xr-x 1 root wheel 72 May 1 2005 /usr/bin/python2.3 ->
                        .../../System/Library/Frameworks/Python.framewor k/Versions/2.3/bin/python

                        --
                        Robert Kern
                        robert.kern@gma il.com

                        "I have come to believe that the whole world is an enigma, a harmless enigma
                        that is made terrible by our own mad attempt to interpret it as though it had
                        an underlying truth."
                        -- Umberto Eco

                        Comment

                        • Thomas Nelson

                          #13
                          Re: python on Mac

                          Ok, I fixed my /usr/bin/python and added /usr/public/bin/ to my PATH in
                          ..profile. Everything seems ok now.
                          Thanks again to everyone for their help.

                          THN

                          Comment

                          • Lawrence D'Oliveiro

                            #14
                            Re: python on Mac

                            In article <1144293362.889 863.146200@i39g 2000cwa.googleg roups.com>,
                            "pierreth" <pthibault33@ya hoo.ca> wrote:
                            [color=blue]
                            >You removed /usr/bin/python! This is a really bad idea[/color]

                            Is there any way to put it back, short of a full system reinstall?

                            Comment

                            • Alex Martelli

                              #15
                              Re: python on Mac

                              Lawrence D'Oliveiro <ldo@geek-central.gen.new _zealand> wrote:
                              [color=blue]
                              > In article <1144293362.889 863.146200@i39g 2000cwa.googleg roups.com>,
                              > "pierreth" <pthibault33@ya hoo.ca> wrote:
                              >[color=green]
                              > >You removed /usr/bin/python! This is a really bad idea[/color]
                              >
                              > Is there any way to put it back, short of a full system reinstall?[/color]

                              There's a free 3rd party tool known as Pacifist to extract part-installs
                              from Apple's system DVDs, but I'm not sure how you'd apply it to Apple's
                              Python -- try asking around on the Pacifist mailing list or site...


                              Alex

                              Comment

                              Working...