[TxMt] Re: using python 3.0.1

Andrei Maxim andrei at andreimaxim.ro
Sat Mar 14 08:26:56 UTC 2009


My install is pretty much vanilla Python 3.0.1. All I changed was the line
added to ~/.bash_login by the Python installer. Notice that ${PATH} is
before the path to the Python 3.0.1 binary files:
# Setting PATH for MacPython 3.0
# The orginal version is saved in .bash_login.pysave
PATH="${PATH}:/Library/Frameworks/Python.framework/Versions/3.0/bin"
export PATH

When running this tiny program I get the expected output:

#!/usr/bin/env python3.0
print ("hallo world")

It really doesn't matter if you use Python 3 as the default version of
Python or not, so there must be something that you changed. AFAIK, the only
change that you really needed to do is either run the command file from the
Python 3.0 folder or add those 4 lines in the .bash_login file (or whatever
shell you use).

Andrei Maxim
http://artfulco.de


On Sat, Mar 14, 2009 at 10:04 AM, Christian <maillists at gmx.de> wrote:

> Thanks for helping me out.
> Now TM also uses v3.0.1. But when I use cmd+R the following error message
> appears with the output:
>
> Error in sitecustomize; set PYTHONVERBOSE for traceback:
> NameError: name 'reload' is not defined
> hallo world
>
> How could this be corrected?
>
> Thanks
> Christian
>
>
> Am 13.03.2009 um 22:14 schrieb Andrei Maxim:
>
> Since I wanted to try out Python anyway, I downloaded the latest Mac
> package (3.0.1 to be precise) and installed it on my computer. At the
> beginning, `python -V` kept saying it's version 2.5.1 and I couldn't find
> any executable called `python3.0` as mentioned above.
> The trick is to run the "Update Shell Profile.command" file that was
> installed in the /Applications/Python 3.0 folder. It will update your
> ~/.bash_login so your $PATH will
> contain "/Library/Frameworks/Python.framework/Versions/3.0".
>
> Obviously, `python -V` will always say `3.0.1` from now on so you might
> want to add it at the end of the path (or at least after /usr/bin/). After
> that, here's what I got:
>
> #!/usr/bin/env python
> import sys
>
> print(sys.version) #=> 2.5.1 (r251:54863, Jan 13 2009, 10:26:13)
>
> and
>
> #!/usr/bin/env python3.0
> import sys
>
> print(sys.version) #=> 3.0.1 (r301:69597, Feb 14 2009, 19:03:52)
>
> Hope that helps.
>
> Andrei Maxim
> http://artfulco.de
>
>
> On Fri, Mar 13, 2009 at 10:46 PM, Alex Ross <tm-alex at rosiba.com> wrote:
>
>>
>> On Mar 13, 2009, at 1:40 PM, Christian wrote:
>>
>> >
>> > Am 13.03.2009 um 21:34 schrieb Peter Cowan:
>> >
>> >> On Fri, Mar 13, 2009 at 1:27 PM, Christian <maillists at gmx.de> wrote:
>> >>>
>> >>> Am 13.03.2009 um 21:12 schrieb Alex Ross:
>> >>>
>> >>>> On Mar 13, 2009, at 12:59 PM, Rob McBroom wrote:
>> >>>>
>> >>>>> On 2009-Mar-13, at 2:15 PM, Christian wrote:
>> >>>>>
>> >>>>>> But I would like to use Python v3 within TextMate when pressing
>> >>>>>> cmd
>> >>>>>> +R.
>> >>>>>> Could that be done in some way? If yes, could you please a
>> >>>>>> minimal
>> >>>>>> example how to code it?
>> >>>>>
>> >>>>>
>> >>>>> Try setting TM_PYTHON to "/path/to/python3.0". It can be set per-
>> >>>>> project or globally in TextMate's preferences. This will make ⌘R
>> >>>>> use
>> >>>>> Python 3, but it might also be enough to break some commands. I
>> >>>>> haven't tried it.
>> >>>>
>> >>>> Commands should use /usr/bin/env python — not TM_PYTHON — so
>> >>>> this
>> >>>> should be ok.  You can also use a hash-bang at the start of your
>> >>>> script, and ⌘R will respect that.
>> >>>
>> >>> May I miss something here, but I used
>> >>>
>> >>> #!/usr/bin/env python
>> >>> print ("hallo world")
>> >>>
>> >>> and the output window of TM says (it's writter directly under the
>> >>> field where your can change the theme) that Python 2.5.1 is used. Is
>> >>> there no way to use 3.0.1?
>> >>
>> >> Try:
>> >>
>> >> #!/usr/bin/env python3.0
>> >> print ("hallo world")
>> >
>> > This produces
>> >
>> > env: python3.0: No such file or directory
>> >
>> > Do I have to add something to env?
>>
>> in terminal do “echo PATH | pbcopy”.  This puts your path on the
>> clipboard.  Now go to TextMate's advanced prefpane, and add a new PATH
>> variable in the Shell Variables tab.  Paste in your PATH from the
>> terminal, and now everything should work (assuming that python3.0 is
>> on the shell PATH).
>>
>> alternatively, in Terminal do “which python3.0” and use the result
>> as your #!.
>>
>> —Alex
>>
>>
>> _______________________________________________
>> textmate mailing list
>> textmate at lists.macromates.com
>> http://lists.macromates.com/listinfo/textmate
>>
>
>
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate
>
>
>
>
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20090314/dfa57da6/attachment.html>


More information about the textmate mailing list