12

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.

hANI
  • 213
  • 3
  • 13
  • 1
    There is a [ticket](https://github.com/conda/conda/issues/4545) regarding this issue, it seems that conda environments will become more portable in future versions. Let's hope it does because it's pretty annoying – Overdrivr Sep 15 '17 at 05:37
  • 2
    Has this been resolved yet, I am about to try working on both operating systems and want an virtual env in each that works? – eric Sep 15 '17 at 13:01
  • 2
    I am wondering just the same. Has it been resolved? I am trying to deploy an application into an ubuntu server and the environment is giving me headaches. – jalazbe Aug 06 '18 at 11:55

2 Answers2

3

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.

  • When I run "conda search libpng" in Windows, I get a bunch of entries including the following two. ............ **libpng -- 1.6.17 -- 0 defaults** ................................................................................................................ **libpng -- * 1.6.22 -- vc14_0 defaults [vc14]** ........................................‌​....................‌​....................‌​............ Should I install the first one? How can I tell conda to change all my default packages to ones that are not "vc" specific? I run "conda update libpng". – hANI Aug 23 '16 at 17:19
  • yes, you should install the first one. Not sure how to switch all the packages automatically, I'm not that experienced with conda. You could probably uninstall the 'vc' packages, install the corresponding 'non-vc' packages and then create the .yml file. – Daniel Kravetz Malabud Aug 23 '16 at 17:39
2

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.

neves
  • 33,186
  • 27
  • 159
  • 192