Reproducing conda environment when packages are no

2020-07-13 10:24发布

I would like to publish the conda environment used for data analysis underlying a scientific paper. I saved the environment to a .yml file using conda env export > environment.yml

I was able to re-create the same environment on a different machine for a while using conda env create -f environment.yml. A couple of months later, creating the environment from the same .yml file fails:

ResolvePackageNotFound: - vc=14.1=h0510ff6_3 - vs2015_runtime=15.5.2=3

Presumably these versions are not longer available on the channels specified in the file? Or could this reflect a different issue?

Perhaps, the exact versions don't matter that much in my specific case but this issue seems to defeat the purpose of saving the environment in the first place. Is there a different command or strategy to save an environment in a way that would be more future-proof?

I am trying to install the environment using miniconda.

conda version 4.5.4

python version: 3.6.5.final.0

Here is the complete .yml file:

    name: jlsocial
channels:
  - conda-forge
  - defaults
dependencies:
  - ca-certificates=2018.4.16=0
  - certifi=2018.4.16=py36_0
  - libiconv=1.15=hfa6e2cd_1
  - libxml2=2.9.8=haffccfe_2
  - libxslt=1.1.32=h5632236_1
  - lxml=4.2.3=py36heafd4d3_0
  - openssl=1.0.2o=hfa6e2cd_1
  - svglib=0.8.1=py36_0
  - svgutils=0.3.0=py36_0
  - backcall=0.1.0=py36_0
  - blas=1.0=mkl
  - bleach=2.1.3=py36_0
  - blosc=1.14.3=he51fdeb_0
  - bokeh=0.12.16=py36_0
  - bzip2=1.0.6=hfa6e2cd_5
  - click=6.7=py36hec8c647_0
  - cloudpickle=0.5.3=py36_0
  - colorama=0.3.9=py36h029ae33_0
  - cycler=0.10.0=py36h009560c_0
  - cytoolz=0.9.0.1=py36hfa6e2cd_0
  - dask=0.17.5=py36_0
  - dask-core=0.17.5=py36_0
  - decorator=4.3.0=py36_0
  - distributed=1.21.8=py36_0
  - entrypoints=0.2.3=py36hfd66bb0_2
  - freetype=2.8=h51f8f2c_1
  - hdf5=1.10.2=hac2f561_1
  - heapdict=1.0.0=py36_2
  - html5lib=1.0.1=py36h047fa9f_0
  - icc_rt=2017.0.4=h97af966_0
  - icu=58.2=ha66f8fd_1
  - imageio=2.3.0=py36_0
  - intel-openmp=2018.0.0=8
  - ipykernel=4.8.2=py36_0
  - ipython=6.4.0=py36_0
  - ipython_genutils=0.2.0=py36h3c5d0ee_0
  - ipywidgets=7.2.1=py36_0
  - jedi=0.12.0=py36_1
  - jinja2=2.10=py36h292fed1_0
  - jpeg=9b=hb83a4c4_2
  - jsonschema=2.6.0=py36h7636477_0
  - jupyter=1.0.0=py36_4
  - jupyter_client=5.2.3=py36_0
  - jupyter_console=5.2.0=py36h6d89b47_1
  - jupyter_core=4.4.0=py36h56e9d50_0
  - kiwisolver=1.0.1=py36h12c3424_0
  - libpng=1.6.34=h79bbb47_0
  - libsodium=1.0.16=h9d3ae62_0
  - libtiff=4.0.9=hb8ad9f9_1
  - locket=0.2.0=py36hfed976d_1
  - lzo=2.10=h6df0209_2
  - m2w64-gcc-libgfortran=5.3.0=6
  - m2w64-gcc-libs=5.3.0=7
  - m2w64-gcc-libs-core=5.3.0=7
  - m2w64-gmp=6.1.0=2
  - m2w64-libwinpthread-git=5.0.0.4634.697f757=2
  - markupsafe=1.0=py36h0e26971_1
  - matplotlib=2.2.2=py36h153e9ff_1
  - mistune=0.8.3=py36hfa6e2cd_1
  - mkl=2018.0.2=1
  - mkl_fft=1.0.1=py36h452e1ab_0
  - mkl_random=1.0.1=py36h9258bd6_0
  - msgpack-python=0.5.6=py36he980bc4_0
  - msys2-conda-epoch=20160418=1
  - nbconvert=5.3.1=py36h8dc0fde_0
  - nbformat=4.4.0=py36h3a5bc1b_0
  - networkx=2.1=py36_0
  - notebook=5.5.0=py36_0
  - numexpr=2.6.5=py36hcd2f87e_0
  - numpy=1.14.3=py36h9fa60d3_1
  - numpy-base=1.14.3=py36h555522e_1
  - olefile=0.45.1=py36_0
  - opencv=3.3.1=py36h20b85fd_1
  - packaging=17.1=py36_0
  - pandas=0.23.0=py36h830ac7b_0
  - pandoc=1.19.2.1=hb2460c7_1
  - pandocfilters=1.4.2=py36h3ef6317_1
  - parso=0.2.0=py36_0
  - partd=0.3.8=py36hc8e763b_0
  - patsy=0.5.0=py36_0
  - pickleshare=0.7.4=py36h9de030f_0
  - pillow=5.1.0=py36h0738816_0
  - pip=10.0.1=py36_0
  - prompt_toolkit=1.0.15=py36h60b8f86_0
  - psutil=5.4.5=py36hfa6e2cd_0
  - pygments=2.2.0=py36hb010967_0
  - pyparsing=2.2.0=py36h785a196_1
  - pyqt=5.9.2=py36h1aa27d4_0
  - pytables=3.4.3=py36he6f6034_1
  - python=3.6.5=h0c2934d_0
  - python-dateutil=2.7.3=py36_0
  - pytz=2018.4=py36_0
  - pywavelets=0.5.2=py36hc649158_0
  - pywinpty=0.5.1=py36_0
  - pyyaml=3.12=py36h1d1928f_1
  - pyzmq=17.0.0=py36hfa6e2cd_1
  - qt=5.9.5=vc14he4a7d60_0
  - qtconsole=4.3.1=py36h99a29a9_0
  - reportlab=3.4.0=py36_0
  - scikit-image=0.13.1=py36hfa6e2cd_1
  - scikit-learn=0.19.1=py36h53aea1b_0
  - scipy=1.1.0=py36h672f292_0
  - seaborn=0.8.1=py36h9b69545_0
  - send2trash=1.5.0=py36_0
  - setuptools=39.1.0=py36_0
  - simplegeneric=0.8.1=py36_2
  - sip=4.19.8=py36h6538335_0
  - six=1.11.0=py36h4db2310_1
  - snappy=1.1.7=h777316e_3
  - sortedcontainers=1.5.10=py36_0
  - sqlite=3.23.1=h35aae40_0
  - statsmodels=0.9.0=py36h452e1ab_0
  - tblib=1.3.2=py36h30f5020_0
  - terminado=0.8.1=py36_1
  - testpath=0.3.1=py36h2698cfe_0
  - tk=8.6.7=hcb92d03_3
  - toolz=0.9.0=py36_0
  - tornado=5.0.2=py36_0
  - traitlets=4.3.2=py36h096827d_0
  - vc=14.1=h0510ff6_3
  - vs2015_runtime=15.5.2=3
  - wcwidth=0.1.7=py36h3d5aa90_0
  - webencodings=0.5.1=py36h67c50ae_1
  - wheel=0.31.1=py36_0
  - widgetsnbextension=3.2.1=py36_0
  - wincertstore=0.2=py36h7fe50ca_0
  - winpty=0.4.3=4
  - wxpython=4.0.1=py36h4cd245c_0
  - yaml=0.1.7=hc54c509_2
  - zeromq=4.2.5=hc6251cf_0
  - zict=0.1.3=py36h2d8e73e_0
  - zlib=1.2.11=h8395fce_2
  - pip:
    - tables==3.4.3
prefix: C:\Users\jlarsch\AppData\Local\Continuum\miniconda3\envs\jlsocial

标签: python conda
2条回答
我想做一个坏孩纸
2楼-- · 2020-07-13 11:00

I had almost exactly the same issue just today. Based on other SO post, I moved the two packages with issues to the pip section of my .yml file. i.e.:

  -pip:
    - vc==14.1=h0510ff6_3
    - vs2015_runtime==15.5.2=3

This seemed to fix the issue for me, though I'm not sure if this is necessarily the best way.

EDIT: On closer inspection, I realise that this didn't solve the issue. Instead, I moved the two packages back to dependencies and just removed the version requirements (it picked up an older version of vc instead). i.e.:

dependencies:
  - vc
  - vs2015_runtime

The resulting versions were:

vc                        14                   h0510ff6_3
vs2015_runtime            14.0.25123                    3

I have the similar setups on both computers, so why this has happened, I'm not entirely sure.

查看更多
家丑人穷心不美
3楼-- · 2020-07-13 11:01

To anyone interested, the reason for this issue is addressed and closed by continuum in: https://github.com/conda/conda/issues/7714 And further discussed in: https://github.com/ContinuumIO/anaconda-issues/issues/10004.

But in short, these two packages have been "revoked" and the new package solver (for anaconda python 3.7) logic does not handle this scenario well.

A possible solution copied from https://github.com/conda/conda/issues/7714:

Steps to fix your environment if you're currently broken:

  1. Note the location of your current base conda environment. For the example here, let's say it's at C:\Users\ScoobyDoo\Anaconda3. You'll also need to know the python version you had before you encountered these errors. Let's say for this example it's python 3.5.
  2. Download miniconda from https://repo.continuum.io/miniconda/Miniconda3-latest-Windows-x86_64.exe. (You can use Miniconda3 or Miniconda2; it doesn't matter.)
  3. Run the miniconda installer, choose install for "Just Me", and then specify a Destination Folder that's different than your current base environment. For this example, we'll put it at C:\temp-conda.
  4. In any command prompt, run the command C:\temp-conda\Scripts\conda.exe install -p C:\Users\ScoobyDoo\Anaconda3 python=3.5 conda
  5. Your normal conda should now be healed, and you can now remove the C:\temp-conda directory if you like.
  6. When you ran the new miniconda installer, your "Anaconda Prompt" shortcut may have been changed. If it no longer works correctly, right click on the "Anaconda Prompt" icon, choose "Properties", and make the Target field point to C:\Users\ScoobyDoo\Anaconda3 instead of C:\temp-conda. Note that you might have to make two changes to the Target field instead of just one. Since the field box is pretty small, it's usually easier to select the field, hit Ctrl-A then Ctrl-C (to select all text then copy), paste the text into an empty notepad file, make your edits, and then copy and paste the edited text back into the Target field.
查看更多
登录 后发表回答