How to share conda environments across platforms
<p>The conda docs at <a href="http://conda.pydata.org/docs/using/envs.html" rel="nofollow">http://conda.pydata.org/docs/using/envs.html</a> explain how to share environments with other people.</p>

<p>However, the docs tell us this is not cross platform:</p>

<pre><code>NOTE: These explicit spec files are not usually cross platform, and      
therefore have a comment at the top such as # platform: osx-64 showing the  
platform where they were created. This platform is the one where this spec
file is known to work. On other platforms, the packages specified might not
be available or dependencies might be missing for some of the key packages
already in the spec.

NOTE: Conda does not check architecture or dependencies when installing 
from an explicit specification file. To ensure the packages work correctly,
be sure that the file was created from a working environment and that it is 
used on the same architecture, operating system and platform, such as linux-
64 or osx-64.
</code></pre>

<p>Is there a good method to share and recreate a conda environment in one platform (e.g. CentOS) in another platform (e.g. Windows)?</p>

<h2>Answer</h2>

<p>This answer is given with the assumption that you would like to make sure that
the same versions of the packages that you generally care about are on
different platforms and that you don't care about the exact same versions of
all packages in the entire dependency tree.  If you are trying to install the
exact same version of all packages in your entire dependency tree that has a
high likelihood of failure since some conda packages have different
dependencies for osx/win/linux.  For example, <a href="https://github.com/conda-forge/otrobopt-feedstock/blob/master/recipe/meta.yaml#L43-L45" rel="nofollow">the recipe for
otrobopt</a>
will install different packages on win vs osx/linux, so the environment list
would be different.</p>

<p>Recommendation: Manually create an environment.yaml file and specify or pin
only the dependencies that you care about.  Let the conda solver do the rest.
Probably worth noting is that conda-env (the tool that you use to manage conda
environments) explicitly recomments that you "Always create your
environment.yml file by hand."</p>

<p>Then you would just do `conda create --file envir</p>

<p>Have a look at the readme for
<a href="https://github.com/conda/conda-env#environment-file-example" rel="nofollow">conda-env</a>.</p>

<p>They can be quite simple:</p>

<pre><code>name: basic_analysis
dependencies:
  - numpy
  - pandas
</code></pre>

<p>Or more complex where you pin dependencies and specify anaconda.org channels to
install from:</p>

<pre><code>name: stats-web
channels:
  - javascript
dependencies:
  - python=3.4   # or 2.7 if you are feeling nostalgic
  - bokeh=0.9.2
  - numpy=1.9.*
  - nodejs=0.10.*
  - flask
  - pip:
    - Flask-Testing
</code></pre>

<p>In either case, you can create an environment with <code>conda create --file environment.yaml</code></p>

<p>If you have a more complex use case or further questions, update the original
question and I'll see if I can't help you a bit more.</p>

python cross-platform conda