Conda create from requirements.txt not finding packages
What I try
conda create --name ml --file ./requirements.txt
I created the requirements.txt file with conda list -e > requirements.txt
on another computer in the past.
requirements.txt:
https://github.com/penguinsAreFunny/bugFinder-machineLearning/blob/master/requirements.txt
Error
PackagesNotFoundError: The following packages are not available from current channels:
- protobuf==3.19.1=pypi_0
- tensorboard-data-server==0.6.1=pypi_0
- pygments==2.10.0=pypi_0
- scikit-learn==1.0.1=pypi_0
- tensorflow-estimator==2.4.0=pypi_0
- flake8==4.0.1=pypi_0
- nest-asyncio==1.5.1=pypi_0 [...]
Current channels:
- https://conda.anaconda.org/conda-forge/win-64
- https://conda.anaconda.org/conda-forge/noarch
- https://repo.anaconda.com/pkgs/main/win-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/win-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://repo.anaconda.com/pkgs/msys2/win-64
- https://repo.anaconda.com/pkgs/msys2/noarch
- https://conda.anaconda.org/pickle/win-64
- https://conda.anaconda.org/pickle/noarch
- https://conda.anaconda.org/nltk/win-64
- https://conda.anaconda.org/nltk/noarch
Question
Why can´t conda find the packages in the channels? I think the missing packages should be in conda-forge, shouldn´t they?
Used Version
conda 4.11.0
Solution 1:
The packages likely are in Conda Forge as suggested, but the build strings, "pypi_0
", indicate that they had been installed from PyPI in the previous environment. The conda list -e
command captures this info, but the conda create
command cannot handle it.
The quickest fix is probably to edit the file to remove the build string specification on those packages. That is, something like:
## remove all PyPI references
sed -e 's/=pypi_0//' requirements.txt > reqs.nopip.txt
## try creating only from Conda packages
conda create -n m1 --file reqs.nopip.txt
Export YAML
Alternatively, serializing to YAML can handle both capturing and reinstalling Pip-installed packages. So, if you still have the old environment around, consider using:
conda env export > environment.yaml
which can recreate (on the same platform) with
conda env create -n m1 -f environment.yaml