Reputation: 681
I'm planning to install Anaconda3 for Python 3.4. Since by default, Mac OS X uses Python2, will install Anaconda3 change the default Python version for the system? I don't want that to happen since Python3 can break backwards compatibility. If it does change the default Python version, how can I avoid that?
Upvotes: 2
Views: 2496
Reputation: 50190
Apple has a built-in system for managing multiple versions of software, and switching between them. But you don't even need to worry about that, because Anaconda installations are self-contained: Everything lives under the top Anaconda installation directory (probably /Applications/anaconda
). The only effect outside this directory is that during installation, Anaconda will offer to modify the PATH
variable in your .bashrc
. If you agree, it will add one line at the end of your .bashrc
, something like this:
PATH="/Applications/anaconda/bin:$PATH"
As you can see, Anaconda puts itself first in the system path. This means that typing python
at the shell prompt will launch python 3, which may not be what you want. I run Anaconda 3.4 like this and have had absolutely no problems with my system, but I did need to modify my own executable python2 scripts that launched python like this:
#!/usr/bin/env python
This is a nice way to find python wherever it is, but in this case it will find python 3-- oops! Changing the above to #!/usr/bin/python
or to #!/usr/bin/env python2
ensures that they continue to work correctly. In my experience this was not necessary with any of the system's own scripts; everything is already set up to find the right python.
Alternative 1: You could decline the PATH modification, and use Anaconda via the launcher. In that case there is no change to the rest of your execution environment. The launcher will start a special bash prompt with the anaconda environment activated, but execution in normal shells is completely unaffected. If you will continue to program a lot in python 2, this may be for you.
Alternative 2: A minimal-impact alternative is to put the anaconda directory last in your path:
PATH="$PATH:/Applications/anaconda/bin"
This ensures that non-anaconda binaries take precedence over anaconda, so python
will start good old /usr/bin/python
(that is, python 2). You can start anaconda's variant by typing python3
, idle3
, etc. I did not have IPython before I installed anaconda, so typing ipython
finds the anaconda version.
Upvotes: 3
Reputation: 180401
No it won't, you can have multiple python installs, once you don't remove your system python or manually change the default you will be fine.
Upvotes: 2