Conda env does not use proper python version

With the latest miniconda, the python version specified for a new environment is not taken into account and python is set to version 3.9. However the exact same code works in linux environments and correctly uses lower python versions like 3.7 or 3.8.

Input code:

if [[ "$TRAVIS_OS_NAME" == 'linux' ]] && [[ "$TRAVIS_PYTHON_VERSION" == 2* ]]; then
MINICONDA_PATH=$HOME/miniconda
chmod +x miniconda.sh && ./miniconda.sh -b -p $MINICONDA_PATH
export PATH=$MINICONDA_PATH/bin:$PATH
conda update -y conda
conda create -n testenv python=$TRAVIS_PYTHON_VERSION pip --yes
source activate testenv
conda install -y numpy scipy scikit-learn cython nose numba matplotlib pytest pytest-cov

Output error:

UnsatisfiableError: The following specifications were found

to be incompatible with the existing python installation in your environment:

Specifications:

  - matplotlib -> python[version='>=2.7,<2.8.0a0|>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|>=3.8,<3.9.0a0']

  - numba -> python[version='2.7.*|3.5.*|3.6.*|>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|>=3.8,<3.9.0a0|>=3.5,<3.6.0a0']

  - pytest-cov -> python[version='>=2.7,<2.8.0a0|>=3.7,<3.8.0a0|>=3.6,<3.7.0a0|>=3.5,<3.6.0a0']

  - scikit-learn -> python[version='>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|>=3.8,<3.9.0a0|>=3.5,<3.6.0a0']

  - scipy -> python[version='>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.8,<3.9.0a0|>=3.7,<3.8.0a0|>=3.5,<3.6.0a0']

Your python: python=3.9

I see a few issues:

  • You are installing Miniconda yourself, with miniconda.sh that you provide. So you don’t need Travis’ Python, it only wastes time and makes things more confusing. Use language: generic.
  • source activate testenv likely has no effect. You should rather use conda activate.
    • This means that you are still using Travis’ Python after than line, producing the effect that you are seeing
1 Like
Imprint