On 11 feb. 2013, at 23:13, "Chip G." <n1mie.c...@gmail.com> wrote:

> On Feb 11, 2013, at 16:12, Maarten Sneep wrote:
> 
>> On 11 feb. 2013, at 21:25, "Chip G." <n1mie.c...@gmail.com> wrote:
>> 
>>> I'm trying to learn Python. I have a book that is helping me along. I'd 
>>> like to use BBEdit as my editor, but I'm having some issues. Part of this 
>>> is an Apple/Fink thing. Part of the problem is that the version of python 
>>> get if I run using 'python' is old (v2.7.1). If I force paths I can get 
>>> v2.7.3 or v3.2.3. As near as I can tell, BBEdit uses the version as if I 
>>> typed 'python' which doesn't work properly with the code in the book. Even 
>>> if I download the authors copy directly. So I'm trying to find a way to 
>>> force BBEdit to use a specific version 2.7.3 or 3.2.3 vice the 2.7.1 it 
>>> keeps preferring. Any ideas?
>> 
>> What's the first line of your script?
> 
> It starts with a line with a '#' and the name of the file. Next after that is:

That is just a plain comment.

> from tkinter import *
> 
> Which works under python 3.2 but not in python 2.7 unless I make it Tkinter.

As expected.

> If I do
> $python myscript.py
> It uses 2.7.1.
> 
> If I do
> $python2.7 myscript.py
> It uses 2.7.3.
> 
> If I do
> $python3.2 myscript.py
> It uses 3.2.3.

So you have three python interpreters in your path. Don't worry, I think I have 
5 or so.

> If I run it from BBEdit it runs behaves the same as the first example. My 
> script, which is calling for Tk to draw a very basic window, doesn't work 
> under 2.7.1 but does under 2.7.3 and 3.2.3. I can test this from the command 
> line perfectly. What I need is a way to control what BBEdit is using.
> 
>> If python 2.7.1 rejects the code, then I assume that the code is written for 
>> python 3 (which is a sensible version to learn these days).
> 
> Nope, works under 2.7.3. And if your statement is true it still doesn't 
> explain how to force BBEdit to use 3.

It does, read again. Right now there is nothing in the file that tells BBEdit 
which python to run, so it uses the plain default ("python", which resolves to 
2.7.1 on your machine).

> 
>> You can try to set the first line to:
>> 
>> #!/usr/bin/env python3
> 
> That looks like bash script, will that work at the beginning of a python 
> script?

That magic #! combination tells the shell to look inside the file to find the 
correct interpreter. It will run /usr/bin/env with the argument 'python3'. This 
is a fancy way of saying that you want your environment to figure out which 
interpreter to run. Works with bash, python, perl, ...

See page 314 in the BBEdit user manual.

> Tried it and BBEdit gave me this error:
> "env: python3: No such file or directory"

So it is working. No, really: BBEdit ran the env tool, but the env tool did not 
find python3. You could try python2.7 instead, or python3.2, but I'd rather get 
python3 working correctly.

What does "which python3" in the terminal say? The python3 command is a generic 
description of, well, python3, without tying you directly to python 3.2.3 or 
even 3.2.x

>> If that doesn't work, try to be more specific (open a terminal, and see 
>> which versions of python are available, typing python and pressing the 
>> tab-key should provide some options).
> 
> See above. 

And now with the full paths.

> 
>> As a last resort, you could use the full path to python:
>> 
>> #!/usr/local/bin/python3
> 
> No, still getting the same errors (tried forcing 2.7.3 too, no dice).

(did you replace the hard-coded path with the output from "which python3.2"?)

Maarten

-- 
-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to