TextWrangler running Python 2.7 after I removed it from my Mac
-
26-02-2021 - |
Вопрос
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.
Решение
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).
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).