Conda environment export to yaml file fails
Asked Answered
K

4

9

I have created an environment but when I try to export it with

conda env export --name ENVNAME > ENVNAME.yml

I get the following error message:

InvalidVersionSpec: Invalid version '(>=': unable to convert to expression tree: ['(']

In response to the question from FlyingTeller, here is what conda list gives (sorry for the long list):

# Name                    Version                   Build  Channel
altair                    3.2.0                    py38_0  
appdirs                   1.4.3                    pypi_0    pypi
appnope                   0.1.0                    py38_0  
asn1crypto                1.3.0                    py38_0  
attrs                     19.3.0                     py_0  
backcall                  0.1.0                    py38_0  
black                     19.10b0                  pypi_0    pypi
blas                      1.0                         mkl  
bleach                    3.1.0                      py_0  
ca-certificates           2020.1.1                      0  
certifi                   2019.11.28               py38_0  
cffi                      1.14.0           py38hb5b8e2f_0  
chardet                   3.0.4                 py38_1003  
click                     7.0                      pypi_0    pypi
cloudpickle               1.3.0                      py_0  
cryptography              2.8              py38ha12b0ac_0  
cycler                    0.10.0                   py38_0  
decorator                 4.4.1                      py_0  
defusedxml                0.6.0                      py_0  
entrypoints               0.3                      py38_0  
et_xmlfile                1.0.1                    py38_0  
ezc3d                     1.2.4            py38hbf1eeb5_0    conda-forge
freetype                  2.9.1                hb4e5f40_0  
idna                      2.8                   py38_1000  
importlib_metadata        1.5.0                    py38_0  
intel-openmp              2020.0                      166  
ipykernel                 5.1.4            py38h39e3cac_0  
ipython                   7.12.0           py38h5ca1d4c_0  
ipython-genutils          0.2.0                    pypi_0    pypi
ipython_genutils          0.2.0                    py38_0  
jdcal                     1.4.1                      py_0  
jedi                      0.16.0                   py38_0  
jinja2                    2.11.1                     py_0  
joblib                    0.14.1                     py_0  
jsonschema                3.2.0                    py38_0  
jupyter_client            5.3.4                    py38_0  
jupyter_core              4.6.1                    py38_0  
kiwisolver                1.1.0            py38ha1b3eb9_0    conda-forge
libcxx                    9.0.1                         1    conda-forge
libedit                   3.1.20181209         hb402a30_0  
libffi                    3.2.1                h475c297_4  
libgfortran               3.0.1                h93005f0_2  
libpng                    1.6.37               ha441bb4_0  
libsodium                 1.0.16               h3efe00b_0  
littleutils               0.2.2                      py_0    conda-forge
llvm-openmp               4.0.1                hcfea43d_1  
markupsafe                1.1.1            py38h1de35cc_0  
matplotlib                3.1.3                    py38_0  
matplotlib-base           3.1.3            py38h9aa3819_0  
mistune                   0.8.4           py38h1de35cc_1000  
mkl                       2019.4                      233  
mkl-service               2.3.0            py38hfbe908c_0  
mkl_fft                   1.0.15           py38h5e564d8_0  
mkl_random                1.1.0            py38h6440ff4_0  
more-itertools            8.2.0                      py_0  
mpmath                    1.1.0                    py38_0  
nb-black                  1.0.7                    pypi_0    pypi
nb_conda_kernels          2.2.2                    py38_0    conda-forge
nbconvert                 5.6.1                    py38_0  
nbformat                  5.0.4                      py_0  
ncurses                   6.1                  h0a44026_1  
notebook                  6.0.3                    py38_0  
numpy                     1.18.1           py38h7241aed_0  
numpy-base                1.18.1           py38h6575580_1  
openpyxl                  3.0.3                      py_0  
openssl                   1.1.1d               h1de35cc_4  
outdated                  0.2.0                      py_0    conda-forge
pandas                    1.0.1            py38h6c726b0_0  
pandas-flavor             0.2.0                      py_0    conda-forge
pandoc                    2.2.3.2                       0  
pandocfilters             1.4.2                    py38_1  
parso                     0.6.1                      py_0  
pathspec                  0.7.0                    pypi_0    pypi
patsy                     0.5.1                    py38_0  
peakutils                 1.3.2                      py_0    conda-forge
pexpect                   4.8.0                    py38_0  
pickleshare               0.7.5                 py38_1000  
pingouin                  0.3.2                      py_0    conda-forge
pip                       20.0.2                   py38_1  
prometheus_client         0.7.1                      py_0  
prompt_toolkit            3.0.3                      py_0  
ptyprocess                0.6.0                    py38_0  
pycparser                 2.19                       py_0  
pygments                  2.5.2                      py_0  
pyopenssl                 19.1.0                   py38_0  
pyparsing                 2.4.6                      py_0  
pyrsistent                0.15.7           py38h1de35cc_0  
pysocks                   1.7.1                    py38_0  
python                    3.8.1                h359304d_1  
python-dateutil           2.8.1                      py_0  
pytz                      2019.3                     py_0  
pyzmq                     18.1.1           py38h0a44026_0  
readline                  7.0                  h1de35cc_5  
regex                     2020.1.8                 pypi_0    pypi
requests                  2.22.0                   py38_1  
scikit-learn              0.22.1           py38h27c97d8_0  
scipy                     1.4.1            py38h44e99c9_0  
seaborn                   0.10.0                     py_0  
send2trash                1.5.0                    py38_0  
setuptools                45.2.0                   py38_0  
six                       1.14.0                   py38_0  
spyder-kernels            1.8.1                    py38_0  
sqlite                    3.31.1               ha441bb4_0  
statsmodels               0.11.0           py38h1de35cc_0  
terminado                 0.8.3                    py38_0  
testpath                  0.4.4                      py_0  
tk                        8.6.8                ha441bb4_0  
toml                      0.10.0                   pypi_0    pypi
toolz                     0.10.0                     py_0  
tornado                   6.0.3            py38h1de35cc_3  
traitlets                 4.3.3                    py38_0  
typed-ast                 1.4.1                    pypi_0    pypi
urllib3                   1.25.8                   py38_0  
wcwidth                   0.1.8                      py_0  
webencodings              0.5.1                    py38_1  
wheel                     0.34.2                   py38_0  
wurlitzer                 2.0.0                    py38_0  
xarray                    0.15.0                     py_0  
xlrd                      1.2.0                      py_0  
xlwt                      1.3.0                    py38_0  
xz                        5.2.4                h1de35cc_4  
zeromq                    4.3.1                h0a44026_3  
zipp                      2.2.0                      py_0  
zlib                      1.2.11               h1de35cc_3  
Knutson answered 13/2, 2020 at 10:46 Comment(4)
Is that the complete error message? Does conda list work for that enviroment?Richia
Yes it does, I have now posted the content.Knutson
@Richia have you tried conda-pack as an alternative to .yml files? conda.github.io/conda-packWeingartner
@brethvoice thank you for the suggestion, but I am not the one with the question, I only edited it and asked for clarificaations. The original author has deleted his/her account as it seemsRichia
L
9

I had run into a similar issue: it is due to some (everlasting) incompatibilities between conda and pip. In my case the pip package nb-black was causing the error: running pip uninstall nb-black followed by conda env export > environment.yml solved it: uninstalling black before exporting your environment might help.

Lockage answered 19/5, 2020 at 9:48 Comment(2)
I can confirm, the same issue. Uninstalling solved export issue.Abstemious
How to find which package is causing the error?Krafftebing
T
0

I had a similar issue, which was caused by my own package, created with setuptools and distributed as wheel. I have used a wrong format, with extra trailing dot, to specify required dependency versions in setup.py of my package.

# setup.py

import setuptools
setuptools.setup(
    name="mypackage",
    version="1.0.0",
    python_requires=">=3.7",
    install_requires=[
        "pandas>=0.25",
        "pyodbc>=4.", # Warning! This should be without trailing dot "pyodbc>=4",
        "requests>=2.26"
    ]
)

In the package installed in a conda environment this information gets saved to %CONDA_PREFIX%/Lib/site-packages/mypackage-1.0.0.dist-info/METADATA. This is where command conda env export fails at reading package versions.

Teleprinter answered 22/2, 2022 at 13:31 Comment(0)
C
0

On windows you can use this method, suggested by RLashofRegas at https://github.com/conda/conda/issues/9624#issuecomment-801623523

In Windows PowerShell you input

cd C:\Users\<user>\Anaconda3\envs\<env name>\Lib\site-packages

then

Get-ChildItem -File -Recurse -Filter METADATA | Select-String "4.7.0<4.8.0" | Select-Object -Unique Path

where you put your error inside the quotation marks, e.g. 4.7.0<4.8.0

This gives the path to the package file, that causes all the troubles. You can either change it's METADATA, or uninstall.

Checkerberry answered 24/11, 2022 at 2:26 Comment(0)
S
0

I had a similar issue. I used the export command in debug mode to identify the package causing the problem. Then, uninstalling the package fixed the issue.

conda env export -vv
Spotty answered 30/11, 2022 at 18:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.