2

I'd like to reset the python terminal command path to the pre-installed version 2.7 on OS X 10.11.3. I never had any path issues on my previous machine, whether it was installing packages to certain versions or avoiding breakages etc. The additions I made to my new machine shouldn't have altered how the python command is set (according to docs and the book I'm using). I don't consider myself a Terminal power-user. I appreciate any help. Details of those additions and what research I have already done follow:

Python 2.6 and 2.7 were pre-installed and the python command launched version 2.7 before I made any changes.

I installed Python 3.5.1 from python.org using python-3.5.1-macosx10.6.pkg, and at that stage python launched ver. 2.7 and python3 launched ver. 3.5.1. This is in-keeping with my previous machine and the book I'm using now: "Python 3 will be installed as /usr/local/bin/python3, leaving any existing Python 2 on your computer unchanged." (Introducing Python by Lubanovic)

I installed Anaconda 3 from continuum.io using the Python 3.5 graphical installer Anaconda3-2.5.0-MacOSX-x86_64.pkg, and following the walkthrough in Introducing Python: "Anaconda installs everything in its own directory (anaconda under your home directory). This means that it won't interfere with any versions of Python that might already be on your computer." The Read Me supports this: "The 'Install for me only' option will install anaconda to the default location, ~/anaconda."

While I am very familiar with certain packages within Anaconda, I have never used Anaconda before. Likewise I didn't think a second install of Python 3.5.1 in a unique directory would mask or conflict either of the other versions.

However, I suspect that this is where I went wrong. The Anaconda Read Me also states: "By default, this installer modifies your bash profile to put Anaconda in your PATH. To disable this, choose "Customize" at the "Installation Type" phase, and disable the "Modify PATH" option. If you do not do this, you will need to add ~/anaconda/bin to your PATH manually to run the commands, or run all anaconda commands explicitly from that path." Please bear in mind, this consideration is not found in the install walkthrough in Introducing Python. I didn't address this one way or the other, so the default was carried out by the installer.

At this stage, both python and python3 launch Python 3.5.1 from Anaconda 2.5.0; only python2.7 launches Python 2.7.

Perhaps there is some way to test how much trouble this might cause.

I haven't explicitly altered or created any aliases, any paths, or any other environment variables. Ned Deily provided thorough-going info in several QnAs. In QnA How to set default Python version in terminal on OS X 10.6.8? he specifies: "The python.org installers for Python 3.x on OS X do not select the shell script modification option by default. You can enable it at installation or you can later run the Update Shell Profile.command file in the corresponding Python x.x folder in the Applications folder. Or you can just manually edit the right profile." I haven't run Update Shell Profile.command of course. Moreover, this info is concurrent with the outcome from my initial 3.5.1 install, but seems contrary to the bash mod info provided in the Anaconda Read Me. But again, I don't know enough about the inner-workings to execute the correct prognosis.

I am to blame for not reconciling the Read Me with the walkthrough prior to the install. I have already researched uninstalling Anaconda, which looks like it creates breakages and hassles. Most of the related QnAs here are concerned with setting or changing the pre-installed system-friendly version to Python 3. After reading through a half-dozen of these QnAs I would be comfortable with performing that change, but I want to do the opposite. It's also possible that I should run tests or check the results of certain terminal commands prior to changing anything. I don't want to attempt anything (the inverse of instructions in a QnA, for example) without expert advice. For an expert I'm sure it's a minor point; thanks for your patience.

Using info provided by waitingkuo in QnA How to set default Python version in terminal on OS X 10.6.8? I have included the current state of my ~/.bash_profile:

# Setting PATH for Python 3.5
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH

# added by Anaconda3 2.5.0 installer
export PATH="/Users/shawnchristopherburke/anaconda/bin:$PATH"
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
"~/.bash_profile" 8L, 267C

In QnA how to change default python version? Adam Vandenberg said that altering which version python launches might not break things in OS X: "Any system software would be using the full path to the system provided Python." That makes me feel better, but I would like to put things back the way they were to ensure compatibility, especially with pre-existing pathnames. Why would Anaconda not default to exercising caution the way python.org installs of Python 3 do? Anxiety is a factor; it is a new machine.

I understand even though I've written at length here, likely there are key details missing. Please let me know if there's any other info I can provide. I'm accustomed to using multiple versions of Python at will, with as few low-level adjustments as possible (first time I've ever looked at .bash_profile for example). So thanks in advance for the education to overcome this hang-up.

Community
  • 1
  • 1
  • If you want to keep both versions you could just comment out the Python 3.5 in your .bash_profile usually. – l'L'l Mar 06 '16 at 23:33
  • Two scenarios: 1) The Python that comes up when you type `python` at the Bash prompt; 2) The version that is executed with a script. The second is easiest to fix. Just use the path for the Python you want at the shebang at the top of the script. The first means changing your path and path order. Type `which python` and say what it shows? – dawg Mar 07 '16 at 03:41
  • Did you just take a dozen paragraphs to say "When I run `python` from Terminal it runs a version I installed. How can I change it back to the Apple-supplied version?" The answer is to change `PATH` back to the default. – miken32 Mar 08 '16 at 22:12

0 Answers0