Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrate anaconda from python v3.6 to v3.7 and preserve all conda and pip packages

The latest anaconda distribution released on Sep2018 uses python v3.7. My existing anaconda distribution uses python v3.6

I would like to upgrade to this latest distribution which uses python v3.7. When I tried to install from the Windows installation executable file, there is no smooth upgrade. If I were to do a clean reinstall, I will have re-install all the conda and pip packages outside of the standard anaconda distribution that I am currently using.

How can I do an anaconda upgrade while preserving all these conda and pip packages that I am currently using that are out of the standard anaconda distribution?

I tried the following command;

conda list --explicit > environment_backup.txt

environment_backup.txt does not seem to contain the pip packages that I have installed.

I am fine if all the conda and pip packages cannot be preserved during the upgrade. However, I would like to have a convenient way to reinstall these conda and pip packages after the new version has been installed. It will be inconvenient if I have to run conda install XXX or pip install XXX commands individually.

like image 742
guagay_wk Avatar asked Nov 15 '18 11:11

guagay_wk


People also ask

Can I install packages with both pip and conda?

Built into Anaconda, conda is a powerful package manager and environment manager that you use with command-line in the Anaconda Prompt for Windows, or in a terminal window for macOS or Linux. pip is the standard package manager for python, meaning you can use it both inside and outside of Anaconda.

Which is better pip or conda?

Conda creates language-agnostic environments natively whereas pip relies on virtualenv to manage only Python environments Though it is recommended to always use conda packages, conda also includes pip, so you don't have to choose between the two.


2 Answers

For the pip installed packages, you can similarly freeze your packages in a requirements.txt file and apply them in the new python version:

pip freeze > requirements.txt

Or to only freeze local packages

pip freeze -l > requirements.txt

To restore the pip packages:

pip install -r requirements.txt
like image 146
Yacine Filali Avatar answered Oct 03 '22 17:10

Yacine Filali


conda env exoprt and import are your friends! From the conda docs:

conda env export > environment.yml

And then:

conda create --name myenv --file environment.yml

This does reinstall all packages but you know exactly which ones you had, including pip packages.

like image 29
roeen30 Avatar answered Oct 03 '22 18:10

roeen30