Victor Goubet
Victor Goubet

Reputation: 15

Problems with python environnements in Anaconda

I have a problem with the management of my environnements on Anaconda. I want to have three environnements, a "classic", another with ortools and a last with django. However, ortools can't be installed by using "conda install ortools", then i have to use pip. My problem is that when i use "pip install --user ortools" in the right environnement it install this package for all my environnements which have the same version of python than the right environnement. How could I fix this ?

Thanks !

Upvotes: 0

Views: 2428

Answers (1)

jkr
jkr

Reputation: 19310

@lucidbrot is correct in their comment. You should not use the --user argument in pip, because that will install into your $HOME directory, which every environment can access.

Here is a series of commands you can use to set up multiple environments, one with ortools

conda create --name ortools-env python=3
conda activate ortools-env
python -m pip install --no-cache-dir ortools
python -c "import ortools"  # No error.
conda create --name django-env python=3 django
conda activate django-env
python -c "import ortools"  # Error: module not found

For reference, the above code uses conda version 4.8.2

Upvotes: 2

Related Questions