How to Switch Different Python Versions while using BBEDIT

735 views
Skip to first unread message

Matthew Miller

unread,
May 24, 2018, 11:44:47 AM5/24/18
to BBEdit Talk
Hello All,

I'm fairly new to BBEDIT, and have recently installed two versions of python on my Mac mini. The original version of python installed was 2.7, however, I also wanted to work with python 3.0 for different projects. Now my previous code that worked with Python 2.7 no longer works after I installed a separate Python version 3.7.  Any recommendations on how to fix this issue? My goal would be to set a default python version through BBEDIT that way I can bounce between the two python versions.

Best,

Matt

Sam Hathaway

unread,
May 24, 2018, 11:46:07 AM5/24/18
to 'Matthew Miller' via BBEdit Talk
How are you invoking Python from BBEdit?
-sam
> --
> This is the BBEdit Talk public discussion group. If you have a
> feature request or would like to report a problem, please email
> "sup...@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+un...@googlegroups.com.
> To post to this group, send email to bbe...@googlegroups.com.
> Visit this group at https://groups.google.com/group/bbedit.

Steve Piercy

unread,
May 24, 2018, 4:33:32 PM5/24/18
to bbe...@googlegroups.com
Try pyenv.

https://github.com/pyenv/pyenv/

It allows you to set your PATH to any version of Python that you
have installed via pyenv.

--steve



On 5/24/18 at 8:43 AM, bbe...@googlegroups.com ('Matthew Miller'
via BBEdit Talk) pronounced:
------------------------
Steve Piercy, Eugene, OR

Steve deRosier

unread,
May 24, 2018, 5:29:12 PM5/24/18
to bbedit
Personally I prefer to use Docker (or choose another container tech). Keeps
the default installs clean, allows me to commit the configuration and I can
work with different dependency tress for different applications quite
easily.

- Steve

--
Steve deRosier
Cal-Sierra Consulting
https://www.cal-sierra.com/

Archibald Campbell

unread,
May 24, 2018, 5:41:38 PM5/24/18
to bbe...@googlegroups.com

For plain scripting, I just use "#!/usr/bin/env python" (for python 2.*), and "#!/usr/bin/env python3" for, uh, Python 3. Works pretty well with a minimum of fuss. But I'm usually doing simple one-file scripts.


Archie

"Néstor E. Aguilera"

unread,
May 24, 2018, 5:49:04 PM5/24/18
to bbe...@googlegroups.com


> On 24 May 2018, at 17:33, Steve Piercy <steve.pi...@gmail.com> wrote:
>
> Try pyenv.
>
> https://github.com/pyenv/pyenv/
>
> It allows you to set your PATH to any version of Python that you have installed via pyenv.
>
> --steve

Beware of not changing the default (used by the OS) version of Python by changing the PATH variable.

"which python" in Terminal will give you the default python. In my system this version is 2.7.10 located at "/usr/bin/python".

On the other hand, "which python3" will give you the default version for python 3.x. In my system this is a sub-sub-folder of "/Library/Frameworks/Python.framework/Versions/...". However, there will be a link to it in "/usr/local/bin"

There are several options now, depending on what you want to do.

If you want to run a BBEdit file from the "shebang menu", you may write at the beginning:

#!/usr/bin/python

for Mac OS python, and if you want it to run version 3.x, you could write

#!/usr/local/bin/python3

Of course, if what you want to do is make a script or module which will run by calling python, then you don't have to write those lines.

In any case, you should be aware the encoding used. Python 3.x expects unicode files unlike Python 2.x which expects ASCII files.

Finally, why would you want to use version 3.7 when the stable one is 3.6?

Hope this helps,

Nestor

===============================================
>
>
>
> On 5/24/18 at 8:43 AM, bbe...@googlegroups.com ('Matthew Miller' via BBEdit Talk) pronounced:
>
>> Hello All,
>>
>> I'm fairly new to BBEDIT, and have recently installed two versions of python on my Mac mini. The original version of python installed was 2.7, however, I also wanted to work with python 3.0 for different projects. Now my previous code that worked with Python 2.7 no longer works after I installed a separate Python version 3.7. Any recommendations on how to fix this issue? My goal would be to set a default python version through BBEDIT that way I can bounce between the two python versions.
>>
>> Best,
>>
>> Matt
>>
>
> ------------------------
> Steve Piercy, Eugene, OR
>

Charlie Garrison

unread,
May 24, 2018, 7:17:40 PM5/24/18
to 'Matthew Miller' via BBEdit Talk

On 25 May 2018, at 1:43, 'Matthew Miller' via BBEdit Talk wrote:

I'm fairly new to BBEDIT, and have recently installed two versions of python on my Mac mini. The original version of python installed was 2.7, however, I also wanted to work with python 3.0 for different projects. Now my previous code that worked with Python 2.7 no longer works after I installed a separate Python version 3.7.  Any recommendations on how to fix this issue? My goal would be to set a default python version through BBEDIT that way I can bounce between the two python versions.

Set your PATH so the 3.7 version is found first. I use .MacOSX/environment.plist for that; there may be other/better ways to do that now.

Then set the script shebang to /usr/bin/env python.

You could set the shebang for each script to path of the 3.7 binary, but you'd be stuck with that until you modified the script shebang again. Using PATH and env is more flexible; just change the PATH and scripts use the new version.

-cng

PS. This method is not specific to python. It works for all scripts using a shebang.

--

Charlie Garrison garr...@zeta.org.au
github.com/cngarrison metacpan.org/author/CNG

Reply all
Reply to author
Forward
0 new messages