Anaconda / osx - change the default version of python

1

I was using python with anaconda on osx 10.8 and the spyder crashed. When I tried to reboot, the launcher showed the spyder as not being installed. I figured the anaconda might have had a problem and rebooted the computer, but the problem continued.

Trying to figure out the source, I noticed that the default version of python had changed:

$ python --version
Python 3.4.1 :: Continuum Analytics, Inc.

I tried to change back using defaults write , redoing the link with ln -sf and creating a alias python=python2.7 , nothing worked.

So I tried using conda to remove python3, but conda remove python3 does not work. Using conda to fetch installed packages returns this:

$ conda search python
Fetching package metadata: ..
(...)
python                       1.0.1                         0  defaults        
                             (...)
                          .  2.7.5                         2  defaults        
                          .  2.7.5                         3  defaults        
                             (...)
                          *  3.4.1                         0  defaults        

I tried to check the Continuum documentation, but they recommend leaving 2.7 as default and creating Anaconda environments to use different versions, which does not help either.

Does anyone have any idea how to change the default back to version 2.7?

(System specifications: anaconda 1.7.0, osx 10.8.5, conda 3.5.2)

    
asked by anonymous 29.05.2014 / 09:46

1 answer

0

Okay, I found a similar problem in Continuum's mailing list.

I solved the problem by reinstalling python using conda:

$ conda install python=2.7
Fetching package metadata: ..
Solving package specifications: .
Package plan for installation in environment /Users/kadu/anaconda:

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    conda-3.5.2                |           py27_0         135 KB
    pycosat-0.6.1              |           py27_0          57 KB
    python-2.7.6               |                2        16.5 MB
    pyyaml-3.11                |           py27_0         149 KB
    requests-2.3.0             |           py27_0         564 KB
    ------------------------------------------------------------
                                           Total:        17.4 MB

The following packages will be UN-linked:

    package                    |            build
    ---------------------------|-----------------
    conda-3.5.2                |           py34_0
    pycosat-0.6.1              |           py34_0
    python-3.4.1               |                0
    pyyaml-3.11                |           py34_0
    requests-2.3.0             |           py34_0

The following packages will be linked:

    package                    |            build
    ---------------------------|-----------------
    conda-3.5.2                |           py27_0   hard-link
    pycosat-0.6.1              |           py27_0   hard-link
    python-2.7.6               |                2   hard-link
    pyyaml-3.11                |           py27_0   hard-link
    requests-2.3.0             |           py27_0   hard-link

Proceed ([y]/n)? 

This method can also be used to choose the default package in anaconda:

$ conda install python=3.4
Fetching package metadata: ..
Solving package specifications: .
Package plan for installation in environment /Users/kadu/anaconda:

The following packages will be UN-linked:

    package                    |            build
    ---------------------------|-----------------
    conda-3.5.2                |           py27_0
    pycosat-0.6.1              |           py27_0
    python-2.7.6               |                2
    pyyaml-3.11                |           py27_0
    requests-2.3.0             |           py27_0

The following packages will be linked:

    package                    |            build
    ---------------------------|-----------------
    conda-3.5.2                |           py34_0   hard-link
    pycosat-0.6.1              |           py34_0   hard-link
    python-3.4.1               |                0   hard-link
    pyyaml-3.11                |           py34_0   hard-link
    requests-2.3.0             |           py34_0   hard-link

Proceed ([y]/n)? 

Note that doing this forces the user to manually reinstall any other packages that are used. I needed to reinstall the spyder, which seems to have caused the bug in the first place and presumably was reinstalled when I tried to launch it in the wrong version. All the other libraries, which I did not try to reinstall, returned to working normally with version 2.7.

    
29.05.2014 / 13:05