Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conda (Python) Virtual Environment is not Portable from Windows to Linux

On my Windows 10 machine, I created a virtual environment using the following command:

>conda env export > environment.yml 

I tried re-creating the virtual environment using the yml file on the Windows system and it worked fine. Then I transferred environment.yml to my Linux machine (Ubuntu 16.04.1) with the same version of conda and python and ran the following in the terminal:

$ conda env create -f environment.yml

I get the following error:

Using Anaconda Cloud api site https://api.anaconda.org
Fetching package metadata .......
Solving package specifications: .
Error: Packages missing in current linux-64 channels:
- jpeg 8d vc14_0
- libpng 1.6.22 vc14_0
- libtiff 4.0.6 vc14_2
- mkl 11.3.3 1
- numpy 1.11.1 py35_1
- openssl 1.0.2h vc14_0
- pyqt 4.11.4 py35_7
- qt 4.8.7 vc14_9
- tk 8.5.18 vc14_0
- vs2015_runtime 14.0.25123 0
- zlib 1.2.8 vc14_3

Most of these packages are available in the linux repo of conda, but with a different flavor. For instance, if I remove vc14_0 from the line that contains the jpeg package in the yml file, that would work just fine. The package vs2015_runtime is not available in linux at all. Nothing gets returned when you run:

conda search vs2015_runtime". 

How can I export my virtual environment in a portable way when working cross-platform, so that all the packages can be installed in Linux as well?

Here is the content of my environment.yml.

like image 771
hANI Avatar asked Aug 23 '16 15:08

hANI


2 Answers

When exporting your environment, use the option --from-history.

conda env export --from-history > environment.yml

It will export just the libs you explicitly installed, and not the dependencies:

Usually some dependencies are platform specific, like your visual studio dependency above. Also the default conda env export put platform specific info in the libs.

It will prevent a lot of troubles and make your export file multi-platform.

Extra tip: always install a lib referencing its version number (e.g.: conda install pandas=1.2.1). Without the version, the command above will export the dependencies without a version, ruining your environment.

like image 175
neves Avatar answered Oct 06 '22 06:10

neves


It looks like you are fetching packages compiled with Microsoft Visual C/C++ Compiler (the vc part of the name). Those packages won't be ABI compatible from Linux as you are trying to do. Simply target the packages that are not Windows-specific.

like image 28
Daniel Kravetz Malabud Avatar answered Oct 06 '22 07:10

Daniel Kravetz Malabud