Johnson Sam
Johnson Sam

Reputation: 1619

Stuck at Solving Environment on Anaconda

I am running OSX Catalina. After downloading Anaconda, I'm having trouble downloading external packages. I tried in both the GUI and the terminal, but the process keeps getting stuck at "Solving environment".

I understand creating a new environment can be a workaround, but I would rather fix the issue at hand.

Any ideas?

Upvotes: 160

Views: 349827

Answers (28)

ATES
ATES

Reputation: 337

Removing and reseting channels and activating my base env solved for me.

conda config --remove channels conda-forge
conda config --set channel_priority flexible
conda activate base

Upvotes: 0

KBurchfiel
KBurchfiel

Reputation: 876

In my case, trying to update a package (e.g. conda update sqlalchemy) caused conda to hang during the 'solving environment' step, but asking Conda to install it (e.g. conda install sqlalchemy) allowed the update to be made. In the latter case, the 'solving environment' step didn't take long at all. I'm not sure why this would be the case, but consider replacing 'update' with 'install' if you're having trouble with update operations.

Upvotes: 0

Lightyears
Lightyears

Reputation: 1378

cannot provide a solution but I have to say that it's not "stuck"

It's just sooooo slow.

Examining conflict for _anaconda_depends anaconda _ipyw_jlab_nb_ext_conf:  51%|███████████████████████▎                      | 33/65 [14:53:43<14:00:25, 1575.79s/i| 

Sometimes it looks like to be stuck because the prompt is not changing, but actually it's because the limited width of console is intercepting the prompt. Conda do have a progress bar and an estimated finish time.


Well yes, the time is deadly long, as long as several days on my old i5-8300H...but if you leave it alone and keep waiting it'll finally work.


20230509 update: Finally it's over after ~48h of running. This is a part of what it'll finally print out.

Package backports.functools_lru_cache conflicts for:
backports.functools_lru_cache
anaconda -> astroid==1.6.5=py27_0 -> backports.functools_lru_cache
conda-build -> conda-verify -> backports.functools_lru_cache
conda-verify -> backports.functools_lru_cache
_anaconda_depends -> backports.functools_lru_cache
prompt-toolkit -> wcwidth -> backports.functools_lru_cache
wcwidth -> backports.functools_lru_cache
spyder -> pylint[version='>=1.0'] -> backports.functools_lru_cache
anaconda -> backports.functools_lru_cache[version='1.4|1.5|1.5|1.6.4',build='py27h9586e20_1|py27_1|py_2|pyhd3eb1b0_0']

Package six conflicts for:
prompt-toolkit -> six[version='>=1.9.0']
conda-verify -> six
anaconda-navigator -> anaconda-client[version='>=1.6.14'] -> six
conda[version='>=4.13.0'] -> conda-package-handling[version='>=1.3.0'] -> six[version='>=1.5.2']
matplotlib-inline -> traitlets -> six
importlib_metadata -> pathlib2 -> six
pip -> html5lib -> six[version='>=1.9']
conda-build -> six
ipython -> prompt-toolkit[version='>3.0.1,<3.1.0'] -> six[version='>=1.9.0']
zipp -> more-itertools -> six[version='>=1.0.0,<2.0.0']
traitlets -> six
anaconda -> asttokens==2.0.5=pyhd3eb1b0_0 -> six[version='>=1.0.0,<2.0.0|>=1.10|>=1.4.1|>=1.5|>=1.9.0|>=1.6.0|>=1.5.2|>=1.15.0|>=1.13.0|>=1.12.0|>=1.4.0|>=1.9|>=1.11.0|>=1.12,<2|>=1.7.3|>=1.10.0|>=1.4']
pickleshare -> pathlib2 -> six
python-dateutil -> six[version='>=1.5']
ipykernel -> packaging -> six

Since it's gonna be reaaaally long, it would almost 100% take all of your console buffer. If you want to analyze the result be sure to redirect it into a file in advance.

Upvotes: 0

Pythonista anonymous
Pythonista anonymous

Reputation: 8950

Many good comments already - let me try to consolidate and add a few more thoughts:

The main background point is that conda is solving a boolean satisfiability problem https://en.wikipedia.org/wiki/Boolean_satisfiability_problem (colloquially: dependency hell https://en.wikipedia.org/wiki/Dependency_hell).

More details here: https://docs.conda.io/projects/conda/en/4.13.x/dev-guide/deep-dive-solvers.html

In the very early days, with relatively few packages, it was not the end of the world. Now, with many packages each with many versions, conda's non-optimised code can take forever.

  1. mamba is a kind of conda clone rewritten in C, so much much faster. Works like a charm. The recommended way to install it is to download mambaforge, otherwise you can install it from anaconda or miniconda. Read the docs: https://mamba.readthedocs.io/en/latest/
  2. If you cannot install mamba, you can use the mamba solver with conda. details on the Anaconda website: https://www.anaconda.com/blog/conda-is-fast-now
  3. mamba and the libmamba solver do not work behind a corporate proxy with zscaler. This is a bug with zscaler, which sends back packets with "_ransfer-Encoding" instead of "Transfer-Encoding". This throws off mamba but not conda. the bug is documented on github https://github.com/mamba-org/mamba/issues/2197 and https://github.com/mamba-org/mamba/issues/2438
  4. If you have access to mamba on one computer but not another, you can: create an environment with mamba based on a yml file which contains only the packages you need (e.g. pandas); once the environment is created, you can export the yml file, which will contain all the dependencies you hadn't specified (e.g. numpy and pandas) as well as the exact versions of each package. You can then create a new environment on the computer with conda only, based on the more detailed yml file. This way, the slower conda doesn't have to solve that package x is at version 2.3 but only version 1.9 works with package y etc
  5. Solution 4 still requires conda to solve a problem, even if a more limited one. If even that takes forever, you can build the environment with mamba then export a requirements file in the format required by pip, and install all the packages with pip in the slower PC. This is detailed here: https://stackoverflow.com/a/75239980/4045275
  6. In general, try to avoid huge environments with loads of packages you do not need. For the same reason, avoid Anaconda, if you can, and just build the environments you need with miniconda, miniforge or mambaforge. If you have projects of different kind, e.g. a set of datascience projects and one of web-related stuff, maintain two separate environments. Smaller environments with fewer packages means less chance for conflicts and faster solving times for conda.
  7. set channel priority to strict. This means that conda will search channels in the order you specified in your .condarc file, so it won't search the 2nd channel if it found all it needed in the 1st https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-channels.html
  8. For the reason above, if you know most of your packages are available in two channels, put the smaller channel first. This is one of the reasons why, with default settings, miniconda is faster than miniforge: because miniconda searches te conda repository, while miniforge the conda-forge, which is much much larger. But be mindful of the licence terms https://www.anaconda.com/blog/anaconda-commercial-edition-faq whereby commercial users require a licence to access the anaconda repository - but not, if I understand correctly, to access conda-forge

If you know of any other potential solutions or suggestions, do share!

Lastly, I'd add that the newer versions of conda introduced parallel downloading, but, in my experience, the main bottleneck is not the download but solving the environment.

Upvotes: 30

In my case, I tried using the Visual Studio code terminal to create a new environment and install python version 3.6 with the following command,

conda create -n env_name python=3.6

But it hangs in the solving environment section.

The solution was to go to the anaconda prompt(run as admin),

first, deactivate base env

conda deactivate

create new env

conda create -n env_name 

activate your new environment

conda activate env_name

Then do whatever you want in the env(in my case, I installed a specific version of python)

conda install python=3.6

Upvotes: 0

a0m0rajab
a0m0rajab

Reputation: 455

I faced the same issue for tensorflow and solved it by doing the next:

  • create new environment conda create -n tf tensorflow
  • moved to the new environemnt conda activate tf
  • downloaded my package there.

it worked and solved the issue, I think this happened due to not completing a previous install and got stuck in the middle.

Upvotes: 0

Ahmad AlMughrabi
Ahmad AlMughrabi

Reputation: 1950

The following works for me.

Spin-off on https://github.com/conda/conda/issues/11919

Instead of waiting (maybe hours) to resolve SAT (A well-known NP-Complete problem) environment, it would be helpful for you to install the faster Conda resolver (https://www.anaconda.com/blog/a-faster-conda-for-a-growing-community). Just so you know, the resolver is not installed by default with Anaconda, so you need to install it manually.

sudo conda update -n base conda

sudo conda install -n base conda-libmamba-solver

conda config --set solver libmamba

Rerun conda install

conda install pytorch torchvision torchaudio pytorch-cuda=11.7 \
 -c pytorch -c nvidia

I hope you find it useful.

Upvotes: 14

chris
chris

Reputation: 21

set conda-forge highest priority, remove defaults channel

conda config --add channels bioconda
conda config --add channels conda-forge
conda config --remove channels defaults
conda config --set channel_priority strict

make sure most your package from conda-forge, not defaults. If it doesn't work, try

conda update --all
conda clean -a //use with caution

Upvotes: 2

Matt Thompson
Matt Thompson

Reputation: 21

I've had this issue running macOS Monterey, with conda taking an age to solve the environment, failing, and causing immense frustration.

My first suggestion would be to install Mamba [1], of which you have two options. If conda does work, but just takes a long time, you can try

conda install mamba -n base -c conda-forge

If conda won't install anything at all, you can try uninstalling anaconda3 using conda install anaconda-clean, then anaconda-clean --yes, then rm -rf anaconda3,rm -rf ~/anaconda3 and rm -rf ~/opt/anaconda3. From there, download the Mambaforge .sh file [1], and run

bash ~/Downloads/Mambaforge-MacOSX-x86_64.sh

Follow the install, and treat mamba exactly how you would treat conda. Then it's simply a matter of selecting your interpreter in your IDE of choice! You'll find that mamba is way faster.

Failing this, you can try using which pip, and then pip install [your package]. I wouldn't advise this one for lots of packages, as you are essentially bypassing the dependancy check, however for small things, it should work fine. Try it, and uninstall it if you get any clashes. Happy fixing!

Upvotes: 2

Gary Andrews
Gary Andrews

Reputation: 1

Another solution that may not have been mentioned is that the dependencies that you may want to install within your conda env are already installed. Using conda-list within your env you may confirm.

With a package such as tethys platform they did not mentioned this and i was left wondering why my conda install process kept getting stuck at the solving stage. Late into the night bingo checked into my env and sure enough the dependencies where already installed. Now can progress to my next phase.

Upvotes: 0

John Johnson
John Johnson

Reputation: 149

For other weary travelers: if you find conda taking hours to solve an environment, try install packages one at a time. Works like a miracle.

Upvotes: 1

el_xino
el_xino

Reputation: 31

After some reading I found out the .condarc file is not created by default (is stated by the official Anaconda documentation. So what I did is delete de .condarc file and then used the following command

conda config --set channel_priority flexible

And then it got unstuck

Then I tried conda update conda just to test it, and everything worked again.

Upvotes: 3

tzelal
tzelal

Reputation: 11

i had the same problem when i tried to install packages for my env i tried the conda env update -f environment.yml even doesn't worked (in yml file i have name: tf2 that i point to update my env still doesnt upgraded) but now which i tried this it worked :d

conda activate tf2
conda env update -n tf2 -f environment.yml --prune

Upvotes: 0

Fiza
Fiza

Reputation: 131

I was having the same issue while creating my conda environment using environment.yml file.

conda env create -f environment.yml

My issue was fixed by updating conda and setting channel priority to strict:

conda update conda
conda config --set channel_priority strict

Upvotes: 3

GILO
GILO

Reputation: 2623

Sounds very simple but make sure you're in your environment

conda activate <Your Environment>

Upvotes: 1

PMM
PMM

Reputation: 21

conda config --remove channels conda-forge

conda config --set channel_priority flexible

This fixed the problem with the solving environment step. After that I was able to update packages (such as conda and anaconda) and sort out various dependency issues.

Upvotes: 2

pthomaid
pthomaid

Reputation: 177

It might be taking long because of package version conflicts. My solution was to install some packages using pip instead of conda install. For example:

pip install tensorflow

Try this in a new environment so it doesn't mess up your existing ones.

Upvotes: 3

Vadiraj k.s
Vadiraj k.s

Reputation: 59

upgrading conda base package has fixed it. ref : https://docs.conda.io/projects/conda/en/latest/user-guide/install/rpm-debian.html

Upvotes: 0

Farhang Amaji
Farhang Amaji

Reputation: 973

for updated conda version over 4.12.0 'Libmamba' with advantages like:

  • Improve conda’s resolving speeds by 50-80%*

  • Maximize backwards compatibility so as to not break any current
    functionality

  • Build the plugin infrastructure for others to create custom solvers

are mentioned in Anaconda's official blog post, A Faster Solver for Conda: Libmamba

so for making libmamba your default solver(make sure your conda version is 4.12): conda install -n base conda-libmamba-solver

and to try it temporarily:conda create -n demo --experimental-solver=libmamba --dry-run install <some package>

Upvotes: 7

Pablo
Pablo

Reputation: 77

I had similar problems trying to install external packages such as graph-tools and I solved it by creating a new environment. I know you prefer other options but it's the only thing that worked for me.

Upvotes: 1

AbdA
AbdA

Reputation: 1010

running

conda config --set channel_priority flexible

worked for me

Update, still ran into some issues so I found Mamba, and oh my god my life changed conda is the worst package manager ever

all my issues were solved when I used mamba

# install mamba
conda install -n base conda-forge::mamba

# use mamba
mamba install pandas

Upvotes: 63

andreiliphd
andreiliphd

Reputation: 145

Please, check that python is actually listed in environment.yml or conda create -n your_environment --file requirements.txt python=3.7. Otherwise, conda is traversing all versions of python available. Check that Python is listed.

Upvotes: 11

Erich Eichinger
Erich Eichinger

Reputation: 1958

you may also want to check your ~/.conda directory permissions. I installed conda on my MacOS using Homebrew and for some reason this directory had only read/write permissions for root. After changing the permissions and following the instructions from above, everything works smooth and fast now

Upvotes: 0

Viacheslav Ivannikov
Viacheslav Ivannikov

Reputation: 722

use this:

conda config --set channel_priority strict

pay attention that it is channel_priority and not priority_channel

Upvotes: 49

SpaceElmo
SpaceElmo

Reputation: 1

This fixed the hang for me. Although the install went on to fail. conda config --set priority_channel strict

Upvotes: -3

Ahmad Hassan
Ahmad Hassan

Reputation: 14

Try installing ANACONDA3 2019-3. I had similar issues but after installing the above version of anaconda they were all fixed.

Upvotes: -3

Jatin Mehrotra
Jatin Mehrotra

Reputation: 11538

The following steps may work to resolve the issue.

conda config --remove channels conda-forge
conda config --add channels conda-forge

if it doesn't work then try this

conda update conda

if nothing works try seeing this github solution, it worked for many.

Upvotes: 71

pooza
pooza

Reputation: 32

Choose one:

  • Start fresh with a new Anaconda installation. Pay attention during installation to make sure that your install path is a subfolder of your home folder, such as /Users/me/anaconda3
  • Start fresh using the .sh installer instead of the .pkg installer. This installer makes it simpler to choose the destination path, and gives you more choice on how you want your shell to behave.

check out the link for more details

This is another answer for environment failure, but for windows OS

Upvotes: -2

Related Questions