How do I upgrade to Python 3.6 using conda?

I am new to Conda package management and want the latest version of Python to use f-lines in my code. Currently my version ( python -V ):

 Python 3.5.2 :: Anaconda 4.2.0 (x86_64) 

How do I upgrade to Python 3.6?

+109
python conda anaconda macos
Jan 08 '17 at 17:56 on
source share
6 answers

Anaconda did not update Python internally until 3.6.

a) Method 1

  1. If you want to update, type conda update python
  2. To update Anaconda, enter conda update anaconda
  3. If you want to upgrade between the main version of Python, for example, from 3.5 to 3.6, you will have to

     conda install python==$pythonversion$ 

b) method 2 - create a new environment (best method)

 conda create --name py36 python=3.6 

c) Get the absolute last python (3.6.5 at the time of writing)

 conda create --name py365 python=3.6.5 --channel conda-forge 

You can see it all here.

Also refer to this for a forced update.

EDIT: Anaconda now has Python version 3.6 here

+148
Jan 08 '17 at 18:12
source share

Creating a new environment will install python 3.6:

 $ conda create --name 3point6 python=3.6 Fetching package metadata ....... Solving package specifications: .......... Package plan for installation in environment /Users/dstansby/miniconda3/envs/3point6: The following NEW packages will be INSTALLED: openssl: 1.0.2j-0 pip: 9.0.1-py36_1 python: 3.6.0-0 readline: 6.2-2 setuptools: 27.2.0-py36_0 sqlite: 3.13.0-0 tk: 8.5.18-0 wheel: 0.29.0-py36_0 xz: 5.2.2-1 zlib: 1.2.8-3 
+33
Jan 09 '17 at 14:57
source share

I found this page with detailed instructions for upgrading Anaconda to a newer version of Python (from Anaconda 4. 0+). The first,

 conda update conda conda remove argcomplete conda-manager 

I also had to conda remove some packages that are not on the official list:

  • backports_abc
  • beautiful soup
  • blaze vein

Depending on the packages installed on your system, you may receive additional UnsatisfiableError errors - just add these packages to the uninstall list. Next, install the Python version,

 conda install python==3.6 

which takes some time, after which it is reported that conda install anaconda-client , so I did

 conda install anaconda-client 

who said it already there. Finally, following the directions

 conda update anaconda 

I did this on the Windows 10 command line, but on Mac OS X everything should be similar.

+19
Jun 23 '17 at 1:09 on
source share

In the past, it was quite difficult for me to try to update on the spot.

Note: my Anaconda use case is an all-in-one Python environment. I am not worried about individual virtual environments. If you use conda to create environments, it can be disruptive because conda creates hard-link environments in your Anaconda/envs .

Therefore, if you use environments, you can first export your environments . After activating your environment, do something like:

 conda env export > environment.yml 

After backing up your environments, if necessary, you can delete the old Anaconda (removing Anaconda is very simple):

 $ rm -rf ~/anaconda3/ 

and replace it by downloading the new Anaconda, for example Linux, 64 bit:

 $ cd ~/Downloads $ wget https://repo.continuum.io/archive/Anaconda3-4.3.0-Linux-x86_64.sh 

( see here for more recent )

then execute it:

 $ bash Anaconda3-4.3.0-Linux-x86_64.sh 
+15
Feb 08 '17 at 3:33
source share

I am using Mac OS Mojave

These 4 steps worked for me.

  1. conda update conda
  2. conda install python==3.6
  3. conda install anaconda-client
  4. conda update anaconda
+2
Mar 12 '19 at 13:32
source share

The best method I've found:

 source activate old_env conda env export > old_env.yml 

Then handle it something like this:

 with open('old_env.yml', 'r') as fin, open('new_env.yml', 'w') as fout: for line in fin: if 'py35' in line: # replace by the version you want to supersede line = line[:line.rfind('=')] + '\n' fout.write(line) 

then manually edit the first ( name:... ) and last line ( prefix:... ) to reflect the name of your new environment, and run:

 conda env create -f new_env.yml 

you may need to manually remove or change the output of the version of several packages for which the pinned version of old_env declared incompatible or missing for the new version of python.

I wish there was a built-in, simpler way ...

0
Jun 13 '18 at 10:37
source share



All Articles