swincas / cookies-n-code

A repo for code review sessions at CAS
http://astronomy.swin.edu.au/
MIT License
30 stars 34 forks source link

Conda needs `ruamel_yaml` to install `ruamel_yaml` #48

Closed DBerke closed 5 years ago

DBerke commented 5 years ago

Today I tried running conda update spyder. I'd just recently fixed an issue where, by downgrading conda from 4.6.4 to 4.5.11, conda would fail with an error about the environment having been modified by a more recent version of conda. (I don't know how relevant this is, but I'll include it anyway.) Anyway, I'd just successfully run conda update conda, and decided to upgrade my editor. I probably should've been suspicious when it wanted to download something like 40 new packages as a result of this simple command, but I left it downloading while I went to lunch.

Getting back after lunch, I found the following error:

ERROR conda.core.link:_execute(656): An error occurred while installing package 'defaults::qt-5.9.7-h468cd18_1'.
Rolling back transaction: done

LinkError: post-link script failed for package defaults::qt-5.9.7-h468cd18_1
location of failed script: /Users/dberke/anaconda3/bin/.qt-post-link.sh
==> script messages <==
<None>
==> script output <==
stdout: 
stderr: cp: /Users/dberke/anaconda3/bin/Assistantapp: No such file or directory
rm: /Users/dberke/anaconda3/bin/Assistantapp: No such file or directory
cp: /Users/dberke/anaconda3/bin/Designerapp: No such file or directory
rm: /Users/dberke/anaconda3/bin/Designerapp: No such file or directory
cp: /Users/dberke/anaconda3/bin/Linguistapp: No such file or directory
rm: /Users/dberke/anaconda3/bin/Linguistapp: No such file or directory
cp: /Users/dberke/anaconda3/bin/pixeltoolapp: No such file or directory
rm: /Users/dberke/anaconda3/bin/pixeltoolapp: No such file or directory
cp: /Users/dberke/anaconda3/bin/qmlapp: No such file or directory
rm: /Users/dberke/anaconda3/bin/qmlapp: No such file or directory

return code: 1

I tried starting Spyder and it failed with the error /bin/bash: /Users/dberke/anaconda3/bin/pythonw: No such file or directory. I then tried conda install spyder, and got the following error:

Traceback (most recent call last):
  File "/Users/dberke/anaconda3/lib/python3.6/site-packages/conda/common/serialize.py", line 19, in get_yaml
    import ruamel_yaml as yaml
ModuleNotFoundError: No module named 'ruamel_yaml'

(cutting out a bunch of stack trace...)

ImportError: No yaml library available.
To proceed, conda install ruamel_yaml

Trying to run conda install ruamel_yaml, however, produced the exact same error, as did any other conda command. I tried running pip install ruamel_yaml, and got an error:

pip install ruamel_yaml
-bash: /Users/dberke/anaconda3/bin/pip: No such file or directory

(This despite the fact that I'd used pip a few hours before.) A which pip pointed me to /usr/local/bin/pip, so I tried using that to install this ruamel_yaml. It ran without giving an error, but I can't import ruamel_yaml in the Python interpreter, and conda keeps throwing the same error. And to top it all off, Spyer is apparently gone as well, so I'm out an editor.

Edit: running ~$ find . -name "ruamel*" gives the following output:

./anaconda3/conda-meta/ruamel_yaml-0.11.14-py36h9d7ade0_2.json
./anaconda3/lib/python3.6/site-packages/ruamel_yaml-0.11.14-py3.6.egg-info
./anaconda3/pkgs/ruamel_yaml-0.11.14-py36h9d7ade0_2
./anaconda3/pkgs/ruamel_yaml-0.11.14-py36h9d7ade0_2/lib/python3.6/site-packages/ruamel_yaml
./anaconda3/pkgs/ruamel_yaml-0.11.14-py36h9d7ade0_2/lib/python3.6/site-packages/ruamel_yaml-0.11.14-py3.6.egg-info
./anaconda3/pkgs/ruamel_yaml-0.15.46-py36h1de35cc_0
./anaconda3/pkgs/ruamel_yaml-0.15.46-py36h1de35cc_0/lib/python3.6/site-packages/ruamel_yaml
./anaconda3/pkgs/ruamel_yaml-0.15.46-py36h1de35cc_0/lib/python3.6/site-packages/ruamel_yaml-0.15.46-py3.6.egg-info
./anaconda3/pkgs/ruamel_yaml-0.15.46-py36h1de35cc_0.tar.bz2

Edit 2: Ah, system pip is Python 2.7, so using it to install doesn't do anything for me. And pip3 fails with

Traceback (most recent call last):
  File "/Users/dberke/anaconda3/bin/pip3", line 6, in <module>
    from pip._internal import main
ImportError: cannot import name 'main'
DBerke commented 5 years ago

Alright, well, to spoil the ending, after several hours of getting nowhere I ended up simply reinstalling a fresh copy of Anaconda since nothing I could find worked. I tried the suggestion given in this comment (https://github.com/conda/conda/issues/7714#issuecomment-417553149) where you make a temporary Miniconda installation and use that to install conda in your original installation, but even that didn't work. (I've since closed the tab with the error output, unfortunately, so I don't remember why not exactly.)

Ultimately a fresh install, creating a new environment, and getting the (fairly small number of) packages I had before set up took less than an hour (faster than I'd expected), so if you ever manage to get your Anaconda installation as hopelessly locked up as I did nuking it from orbit and rebuilding from scratch may be faster than trying to salvage it. If conda still works for you (it didn't for me) you can list all the packages in your environment with conda list --name ENVNAME ahead of time so you don't have to remember them yourself.