You can install 2.7.
It is generally considered a bad, bad idea to change the native version, because built-in apps and frameworks are written for specifically the version that is bundled.
The way to go is to install 2.7 along side 2.6. This is generally considered the best practice.
That way, you can use 2.7 when you want, and apps will still use the version they were made for.
Go to this page to get the Python for Mac installer. Follow the directions to install it. Then, to access the new version, type python2.7
in Terminal. You'll have a Python shell of the version specified.
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).
Best Answer
if you can use pkgutil on a file you know for sure came from the python 2.7 you installed you can do
Copy/paste the pkgid in
That will spit out a list of files that came with python 2.7 -- you can now go ahead and remove them (with all due care not to remove any unrelated file in the same directories etc).