3

I have removed Python 2.7 from my machine, using instructions provided here: How to uninstall Python 2.7 on a Mac OS X 10.6.4? (Using the top voted/accepted answer's instructions)

However, when I run my scripts using TextWrangler and look at some of the errors generated, it is still indicating that the error originated from Python 2.7 directory, which I have already deleted, and can't see it using ls.

Any idea how to force TextWrangler to run Python 3 instead?

I am running OS X Yosemite 10.10.5 on MacBook Pro mid 2012.

5
  • What is the output if you type which python and /usr/bin/env python and echo $PATH? I'm guessing one of the command in the 10.6 recipe failed - perhaps silently and you don't have python3 first in your PATH. Also, that linked question has about 5 different recipes - consider listing what steps you took on your Mac...
    – bmike
    Feb 12 '16 at 23:31
  • 1
    which python returned: /usr/bin/python. /usr/bin/env python started running python 2.7 and echo $PATH returned this long thing: /Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/texbin. It's really weird because I don't see 2.7 anywhere in the directory after I deleted them using the instructions in that link I posted, i used the top vote/accepted answer.
    – gptt916
    Feb 13 '16 at 5:06
  • So how would I go about properly removing it? I am not too experienced with linux and bash.
    – gptt916
    Feb 13 '16 at 5:12
  • I assume you read all of the warnings about removing the system Python version (lots of OS X things can break, and afaik, getting it back requires an OS reinstall). With this in mind, I think the easiest way to get TextWrangler to use Python3 is probably to install it with Homebrew. Once there, just symlink /usr/local/bin/python to the Python3 installed with Homebrew. I can make this into an answer if this is a viable solution for you. Feb 17 '16 at 15:40
  • As a quick aside: if you only need to run scripts with Python 3, installing it with Homebrew and starting your Python scripts with #! /usr/bin/env python3 or /usr/local/bin/python3 should run the respective file using Python 3. You can check by running import sys; print(sys.version) in a new file with the python3 set in the first line. Feb 17 '16 at 16:08
1

As the root of your question seems to be, "How can I run scripts via TextWrangler in Python 3 (rather than 2.7)?", I'll provide an answer to that. (Please let me know if I've misunderstood).

As I'm not sure how you've chosen to install Python 3, I'd suggest working with Homebrew and installing python and python3 with the command brew install python python3 once you've gotten Homebrew up and running.

Homebrew defaults to installing software to /usr/local/bin/, so make sure that is present in your PATH variable.

Once Python 3 is installed, you can create a new TextWrangler document and enter the following code to test:

#!/usr/bin/env python3

import sys
print(sys.version)

Then, run the script by going to #! -> Run in the TextWrangler menu (see attached image).

TextWrangler "Run script"

The output (shown in a new window by default) should give you your system and Python information. In my case, the results were:

=========================================================================
Feb 18, 2016, 15:07:45
untitled text
-------------------------------------------------------------------------
3.5.1 (default, Dec  7 2015, 21:59:10) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)]

Alternately, you can directly input the path to your python3 executable in line 1 (/usr/local/bin/python3 is the default for Homebrew).

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .