talmolab / sleap

A deep learning framework for multi-animal pose tracking.
https://sleap.ai
Other
432 stars 96 forks source link

GUI won't launch - git issue (Mac OS 11.01) #420

Closed afmcelroy closed 3 years ago

afmcelroy commented 3 years ago

I use a Macbook and have previously had success using sleap in conjunction with Colab. After installing the recent Mac OS update (11.01 Big Sur), I started having an issue where the labeling GUI completely failed to launch.

sleap-diagnostic revealed an error (in the GIT section) in this format:

xcrun: error: invalid active developer path (Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun (reproduced from a tutorial but this is likely identical to the error I got)

Apparently, Xcode will sometimes silently delete itself during OS updates, leaving the shell with no ability to communicate with git. So I reinstalled Xcode (and ensured it was on the expected path as shown above), but the GUI still wouldn't launch, and I was getting this error in sleap-diagnostic:

call to git failed fatal: not a git repository (or any of the parent directories): .git Checking confirmed there was no git repository either within sleap, or indeed anywhere else in my files. I downloaded the latest version of git with Homebrew, but nothing changed.

My understanding of git is extremely cursory, but I figured using git init in my root directory would at least cause me to have a different problem. Sure enough:

call to git failed fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' HEAD Using pip uninstall sleap and then reinstalling (without uninstalling Tensorflow or disabling my sleap_env) also failed to fix the issue.

Here is the current output of sleap-diagnostic, as of me successfully reinstalling sleap 1.0: sleap-diagnostic-reinstallation.docx (posted as a docx because Github didn't like the tables)

Is this fixable or do I need to revert to a backup? The shell I am using is bash rather than zsh because of zsh having problems with conda

talmo commented 3 years ago

Hey @afmcelroy,

Let's try a couple of troubleshooting steps:

  1. Try (re-)installing xcode: sudo xcode-select --install and then sleap-label.
  2. If that doesn't work, it might just be set to the wrong path. Find out the path on your system: xcode-select --print-path and update it to sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/ but replace the path to with the one printed by the first command. It should not throw an error saying the path is invalid.
  3. You might have to reinstall SLEAP, either in a new environment or by: pip uninstall -y sleap PySide2 and pip install sleap

Give it a go and let me know if that works for you :)

Cheers,

Talmo

afmcelroy commented 3 years ago

Hi Talmo, thanks for the response!

  1. Reinstalling xcode lends xcode-select: error: command line tools are already installed, use "Software Update" to install updates. No change in sleap-label's behavior.
  2. Updating the path also doesn't change anything but I'm not clear I understand you: xcode-select --print-path lends /Library/Developer/CommandLineTools. Should I be switching to /Library/Developer/CommandLineTools (which is what I did), or switching to some combination of the path I got and your example? Again, no change in sleap-label.
  3. Uninstalling and reinstalling in the same environment still caused the GUI to not launch but this time the shell threw an error: /Applications/anaconda3/envs/sleap_env/lib/python3.6/site-packages/shiboken2/files.dir/shibokensupport/signature/parser.py:97: FutureWarning: split() requires a non-empty pattern match. return [x.strip() for x in split(argstr) if x.strip() not in ("", ",")]. Before the GUI would just silently not launch. The same error occurred after I quit out and tried to run sleap-label again in a new terminal window. The only apparent difference in sleap-diagnostic is that I now have sleap 1.0.9 instead of 1.0.0 (The version of shiboken2 is the same: 5.14.1. I will post a new file if you think there is something I might have missed but the outputs appeared the same with no new errors.)

So I created a new environment (conda create -n sleap_env2 python=3.6 -y). I decided to install sleap 1.0.0 because of the new error. Running sleap-label did not cause the shell to throw an error again, but the GUI still does not appear. The output of sleap-diagnostic for this instance is identical to the one in the original environment.

talmo commented 3 years ago

Hi @afmcelroy,

Hi Talmo, thanks for the response!

  1. Reinstalling xcode lends xcode-select: error: command line tools are already installed, use "Software Update" to install updates. No change in sleap-label's behavior.

Alright, worth a try!

  1. Updating the path also doesn't change anything but I'm not clear I understand you: xcode-select --print-path lends /Library/Developer/CommandLineTools. Should I be switching to /Library/Developer/CommandLineTools (which is what I did), or switching to some combination of the path I got and your example? Again, no change in sleap-label.

Yes, you should use sudo xcode-select -switch /Library/Developer/CommandLineTools (which sounds like you did).

  1. Uninstalling and reinstalling in the same environment still caused the GUI to not launch but this time the shell threw an error: /Applications/anaconda3/envs/sleap_env/lib/python3.6/site-packages/shiboken2/files.dir/shibokensupport/signature/parser.py:97: FutureWarning: split() requires a non-empty pattern match. return [x.strip() for x in split(argstr) if x.strip() not in ("", ",")]. Before the GUI would just silently not launch. The same error occurred after I quit out and tried to run sleap-label again in a new terminal window. The only apparent difference in sleap-diagnostic is that I now have sleap 1.0.9 instead of 1.0.0 (The version of shiboken2 is the same: 5.14.1. I will post a new file if you think there is something I might have missed but the outputs appeared the same with no new errors.)

This should be fine (it's just a warning).

So I created a new environment (conda create -n sleap_env2 python=3.6 -y). I decided to install sleap 1.0.0 because of the new error. Running sleap-label did not cause the shell to throw an error again, but the GUI still does not appear. The output of sleap-diagnostic for this instance is identical to the one in the original environment.

Okay, do you think you could try out the solution in this StackOverflow answer? In particular, this looks promising (maybe skip the other commands):

Xcode -> Preferences -> Locations -> Command Line Tools and confirm you have current Xcode version selected there.

A couple more diagnostics:

  1. What happens when you do a ls -lah /Library/Developer/CommandLineTools/usr/bin/?
  2. Are you still getting the error saying xcrun: error: invalid active developer path (Library/Developer/CommandLineTools) even after doing the reinstall and sudo xcode-select -switch /Library/Developer/CommandLineTools?
talmo commented 3 years ago

One more: try sudo xcode-select --reset?

afmcelroy commented 3 years ago

Are you still getting the error saying xcrun: error: invalid active developer path (Library/Developer/CommandLineTools) even after doing the reinstall and sudo xcode-select -switch /Library/Developer/CommandLineTools?

No, I am no longer having this error - I definitely have xcode installed and it's definitely on the right path but the GUI still won't launch. The error i'm seeing come up in sleap-diagnosic is this one:

call to git failed fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' HEAD

which was originally call to git failed fatal: not a git repository (or any of the parent directories): .git, before I fumbled around and put an empty git repository in my root directory in the hopes it might fix something.

It seems that when I try to launch sleap, it's able to find xcode, but either xcode or sleap is not able to talk to git for whatever reason. Updating git with homebrew didn't help.

This is the output of ls -lah /Library/Developer/CommandLineTools/usr/bin/: ls-lah-1.docx I can see a couple files related to git, but no .git which based on my understanding is the necessary one?

talmo commented 3 years ago

Hi @afmcelroy,

Sorry we're still dealing with this issue! Mac updates are frustrating :(

So let's just go after the symptom instead of the problem and try just installing from the sources on GitHub. This shouldn't be preventing you from opening the GUI, but if it still doesn't work, maybe we'll at least get a different error message.

First, clone SLEAP at the current version:

git clone https://github.com/murthylab/sleap.git --branch v1.0.9

or if you want to give it a try, the newest pre-release:

git clone https://github.com/murthylab/sleap.git --branch v1.0.10a9

If you don't mind installing SLEAP in your base environment (not recommended), you can simply install it from source like this:

cd sleap
pip install -e .

Preferably, create a new environment and then install it from source:

conda create -n sleap_src_env python=3.6 -y
conda activate sleap_src_env
cd sleap
pip install -e .

From this point you should be able to run sleap-label and hopefully see a non-git related error if you can't.

afmcelroy commented 3 years ago

Serves me right for using a Mac, honestly 😛

I followed the above steps, but it didn't like pip install -e because there was no argument. Trying pip install -e git+https://github.com/murthylab/sleap.git also didn't work because it didn't find an egg or whatever it needs for an editable install (I didn't save the message and probably should have). So I tried to install it from the repo in the normal fashion: pip install git+https://github.com/murthylab/sleap.git. Installation successful but still nothing - GUI still won't launch, and I'm still getting this error in sleap-diagnostic:

call to git failed fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' HEAD which seems downright bizarre now that I installed it directly from the repo.

Would installing it in editable mode be likely to change this behavior?

talmo commented 3 years ago

Right so you're still going to get the git error if it's using the old sleap installation -- did you maybe install it in your base environment? You can check by seeing the path you get from where sleap-diagnostic.

Anyway, the issue was that you needed to do pip install -e . (note the dot after -e, denoting the current directory). To be safe you could try running these commands exactly (line-by-line):

conda create -n sleap_109 python=3.6
conda activate sleap_109
cd ~
git clone https://github.com/murthylab/sleap.git --branch v1.0.9 sleap_1.0.9
cd sleap_1.0.9
pip install -e .
afmcelroy commented 3 years ago

Ah, I see. You can tell my knowledge of git is nonexistent.

The first time I tried following the commands I still got the git error (I mistyped an accent instead of a tilde on cd and broke the pathing somehow) but I tried again in a fresh environment (sleap-again), copying and pasting the commands, and am no longer getting a git error. The GUI is still not launching. Here is the output of sleap-diagnostic; there are no visible errors to my eye, but then, I wouldn't know what I'd be looking for: sleap-diagnostic-src-install.docx I got the same warning about shiboken2 but I assume it still doesn't matter.

For context, when I say the GUI won't launch, sleap is still doing something: when I close the terminal window after using sleap-label it asks me if I want to terminate the current process, and the icon of a running python script will show up in the taskbar once i use the command. The GUI just never comes up: not after clicking the task bar icon, not after a wait of up to 30 minutes.

talmo commented 3 years ago

Awesome -- now we're getting somewhere!

So this sounds like it might be this issue: https://stackoverflow.com/questions/64818879/is-there-any-solution-regarding-to-pyqt-library-doesnt-work-in-mac-os-big-sur/64856281

There's two fixes that are proposed:

  1. Set an environment variable before launching sleap:

    conda activate sleap_again
    export QT_MAC_WANTS_LAYER=1
    sleap-label
  2. If that doesn't work, try downgrading the GUI dependencies:

    conda activate sleap_again
    pip uninstall PySide2
    pip uninstall shiboken2
    pip install PySide2==5.13

    if that doesn't work, repeat these steps but replace the last line with pip install PySide2==5.15.

Give these a go and let me know if they work for you!

afmcelroy commented 3 years ago

The first one fixed it! The GUI is back up and everything seems to be normal. Thanks for all the help! I will go ahead and close the issue.