Reputation: 33
Trying to install CPLEX to use for optimisation. This is what happens:
conda install -c ibmdecisionoptimization cplex
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: |
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
failed
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
- cplex -> python[version='2.7.*|3.5.*|>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|>=3.5,<3.6.0a0']
Your python: python=3.8
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
So I guess I have the wrong version of Python installed. How do I change this?
Also, is this the correct way of using it in code?
import pulp
import cplex
prob.solve(pulp.CPLEX_CMD())
Upvotes: 0
Views: 1651
Reputation: 11631
The easiest solution is to create a new virtual environment. In that case, to specify your python version, you can pass the package version in the conda create command. For example, if I want a new environment named env_w_python36 using python 3.6, run the following command:
conda create -n env_w_python36 python=3.6
You can then check that the right version of python is installed in your environment:
$ conda activate env_w_python36
(env_w_python36) $ python --version
Python 3.6.12 :: Anaconda, Inc.
Another solution might be to downgrade/upgrade your python version in your current environment, by requesting a specific version :
conda install python=3.6
Note that it can create a lot of conflicts with already installed packages. Whenever you want to use a different version of python, creating a new environment is almost always the way to go.
Upvotes: 1