Python3 Shebang Woes

53 views
Skip to first unread message

Paul Gobble

unread,
Mar 5, 2020, 7:06:11 AM3/5/20
to BBEdit Talk
I'm using BBedit 13.0.5 on Mac Os 10.15.3 as my editor while I try to learn a bit of Python3.  

#!/usr/bin/env python3
print('Hello World')

Baby steps.

I try to execute this from the Run menu item in the #! menu and get

/Users/.../Scripts/python_test-01.py: line 1: #!/usr/bin/env: No such file or directory

Then I try to use the direct path in the shebang line

#!/usr/bin/python3
print('Hello World')

and get a very similar response

/Users.../Scripts/python_test-01.py: line 1: #!/usr/bin/python3: No such file or directory

So I go investigate in the Terminal app and look around.

Emonda:bin paul$ pwd

/usr/local/bin

Emonda:bin paul$ whereis python3

/usr/bin/python3

Emonda:bin paul$ whereis env

/usr/bin/env

Emonda:bin paul$ 


Both env and python3 are right where I said they were in the shebang line, but interpreter can't find them!  

Can anyone help me out here?  What am I missing?

Thanks,
Paul

Dan White

unread,
Mar 5, 2020, 8:20:24 AM3/5/20
to bbe...@googlegroups.com
Try

#!/usr/bin/python3


Dan White | d_e_...@icloud.com
------------------------------------------------
“Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.”  (Bill Waterson: Calvin & Hobbes)
--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/733447e6-cbe5-4b02-bb82-bd26d026e1bd%40googlegroups.com.

Paul Gobble

unread,
Mar 5, 2020, 12:54:32 PM3/5/20
to BBEdit Talk
LinuxDan

The line of code you suggested is exactly the line I've been using, and I get 

#!/usr/bin/python3: No such file or directory

But in the shell I'll set that it is there

Emonda:bin paul$ whereis python3
/usr/bin/python3

I'm stumped.
To unsubscribe from this group and stop receiving emails from it, send an email to bbe...@googlegroups.com.

Rick Yentzer

unread,
Mar 11, 2020, 7:01:23 PM3/11/20
to BBEdit Talk
Paul,

Have you tried to run that file from the command line? I wonder if BBEdit is not finding python3 in your $PATH variable.

#!/usr/local/bin/python3
print('Hello World')


I created a test file with my location of python 3 and BBEdit ran the file correctly. python 3 is in my $PATH varaible.

In my case, running echo $PATH yields

/usr/local/bin:/usr/bin:/bin: ...


Thanks,

RY

Paul Gobble

unread,
Mar 11, 2020, 7:25:52 PM3/11/20
to bbe...@googlegroups.com
Rick,

Thanks for the suggestion.  

I thought I posted to the group before: It turns out the problems was BBEdit’s default was to save the file with UTF-8 with BOM.  That was enough to make the file readable, but the first like, the Shebang line, started with an extra invisible character which kept throwing the interpreter off.  I resaved the file as UTF-8 No BOM and everything worked just fine.  

- Paul

-- 
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/59297f9e-334d-408f-9d76-5b0429d89cde%40googlegroups.com.

Rich Siegel

unread,
Mar 11, 2020, 10:28:54 PM3/11/20
to bbe...@googlegroups.com
On 3/11/20 at 7:25 PM, pa...@paulgobble.com (Paul Gobble) wrote:

>I thought I posted to the group before: It turns out the
>problems was BBEdit’s default was to save the file with UTF-8
>with BOM.

The factory default is to *not* use a BOM, but it's certainly
possible to change the preference, and you may have done so
without fully realizing the subsequent implications. :-)

R.
--
Rich Siegel Bare Bones Software, Inc.
<sie...@barebones.com> <https://www.barebones.com/>

Someday I'll look back on all this and laugh... until they
sedate me.

Reply all
Reply to author
Forward
0 new messages