biocore / songbird

Vanilla regression methods for microbiome differential abundance analysis
BSD 3-Clause "New" or "Revised" License
54 stars 25 forks source link

More QIIME 2 / TensorFlow conda-forge installation problems ._. #126

Open fedarko opened 4 years ago

fedarko commented 4 years ago

So, installing Songbird via conda-forge into a fresh QIIME 2 2020.2 environment now works, at least insofar as getting Songbird installed. (Like, importing Songbird into python works, running songbird multinomial --help works, ...)

However, when you run qiime dev refresh-cache, the following error rears its head:

QIIME is caching your current deployment for improved performance. This may take a few moments and should only happen once per deployment.
Traceback (most recent call last):
  File "/home/marcus/Software/miniconda2/envs/q2-2020.2b/bin/qiime", line 11, in <module>
    sys.exit(qiime())
  File "/home/marcus/.local/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/marcus/.local/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/marcus/.local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/marcus/.local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/marcus/.local/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/marcus/.local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/marcus/Software/miniconda2/envs/q2-2020.2b/lib/python3.6/site-packages/q2cli/builtin/dev.py", line 31, in refresh_cache
    import q2cli.core.cache
  File "/home/marcus/Software/miniconda2/envs/q2-2020.2b/lib/python3.6/site-packages/q2cli/core/cache.py", line 404, in <module>
    CACHE = DeploymentCache()
  File "/home/marcus/Software/miniconda2/envs/q2-2020.2b/lib/python3.6/site-packages/q2cli/core/cache.py", line 61, in __init__
    self._state = self._get_cached_state(refresh=refresh)
  File "/home/marcus/Software/miniconda2/envs/q2-2020.2b/lib/python3.6/site-packages/q2cli/core/cache.py", line 107, in _get_cached_state
    self._cache_current_state(current_requirements)
  File "/home/marcus/Software/miniconda2/envs/q2-2020.2b/lib/python3.6/site-packages/q2cli/core/cache.py", line 200, in _cache_current_state
    state = self._get_current_state()
  File "/home/marcus/Software/miniconda2/envs/q2-2020.2b/lib/python3.6/site-packages/q2cli/core/cache.py", line 238, in _get_current_state
    plugin_manager = qiime2.sdk.PluginManager()
  File "/home/marcus/Software/miniconda2/envs/q2-2020.2b/lib/python3.6/site-packages/qiime2/sdk/plugin_manager.py", line 54, in __new__
    self._init(add_plugins=add_plugins)
  File "/home/marcus/Software/miniconda2/envs/q2-2020.2b/lib/python3.6/site-packages/qiime2/sdk/plugin_manager.py", line 81, in _init
    plugin = entry_point.load()
  File "/home/marcus/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2433, in load
    self.require(*args, **kwargs)
  File "/home/marcus/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2456, in require
    items = working_set.resolve(reqs, env, installer, extras=self.extras)
  File "/home/marcus/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 791, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (opt-einsum 0+untagged.53.g6ab433b.dirty (/home/marcus/Software/miniconda2/envs/q2-2020.2b/lib/python3.6/site-packages), Requirement.parse('opt-einsum>=2.3.2'), {'tensorflow'})

For reference, opt_einsum is a dependency of TensorFlow. The funky thing is that this library actually is getting installed when you install Songbird via conda-forge: see this Qurro Travis build log for an example (just ctrl-C for einsum).

But here's the kicker. opt_einsum is getting installed, but TensorFlow is exploding because it expects opt-einsum to be installed. Yeah, apparently the hyphen (-) vs. underscore (_) actually separates two different "packages", at least from conda-forge's perspective (hyphen, underscore).

The "underscore" version (opt_einsum) is apparently the actively maintained version of this package, but the "hyphen" version (opt-einsum) actually works with TensorFlow (it seems like QIIME 2 is checking the currently-installed package versions against TensorFlow's setup.py or something, and the setup.py hasn't been updated to point to opt_einsum instead of opt-einsum yet).

A solution (documented by some brave souls who have also run into this problem) corroborates that we can get around this by literally adding a requirement for opt-einsum to the conda-forge recipe. (Similarly, running conda install -c conda-forge opt-einsum after conda-installing songbird fixes the QIIME 2 errors. The downside seems to be that now there are two opt[-_]einsum packages installed in the conda environment, which is probably pretty confusing for everyone involved.)

So, there are a few ways around this (updating the songbird recipe, updating the songbird readme, raising this issue with the tensorflow conda-forge maintainers, just asking users to pip install songbird for the time being, ...) -- hopefully getting around this shouldn't be too bad.

mortonjt commented 4 years ago

I'm actually having some trouble reproducing this issue - I was able to install songbird in a qiime2-2020.2 environment without the seeing the qiime dev refresh-cache errors you ran into.

But agree with the pip install recommendation - thank you for pushing that PR in.

fedarko commented 4 years ago

I suspect that you have both versions of opt[_-]einsum installed -- I had the same thing happen to me, it worked the first time in a "old" Q2 2020.2 environment that I'd been using for a while, but when I installed a new Q2 2020.2 environment and then immediately tried to install Songbird I got the error.

If my hypothesis is correct :), I think running conda list | grep einsum in your environment should show two packages... if this isn't the case, then you may have figured out a way past this issue, so that's also useful ;)

Alxdu commented 4 years ago

In a vanilla Q2.2020.2 environment, the songbird install only worked with python -m pip install songbird; whereas pip install songbird gives: _ModuleNotFoundError: No module named 'pip._internal'. Thought this could help others

mortonjt commented 4 years ago

Hi @Alxdu thanks for reporting this issue. I'm having trouble producing this issue as well. Do you have pip installed? You can verify with which pip.

It is also worthwhile conda-forge install via conda install songbird -c conda-forge if there are issues with pip.

Alxdu commented 4 years ago

I've only seen the issue in the conda environment created by the default qiime2-2020.2 install. which pip /home/user/miniconda3/envs/qiime2-2020.2/bin/pip conda list pip 20.0.2 py_2 conda-forge

I haven't tried a standalone songbird install. But like I mentioned, running python -m pip install songbird in the qiime env works well. I was able to run through the demo RedSea data. No issues to report after installation.

Side note: the same installation process worked on a windows machine within Windows Subsystem for Linux (Ubuntu 20.04). Works well in Windows.

mortonjt commented 3 years ago

Ok, I'm able to reproduce these issues. FYI : not sure if the pip install will work if you want to get the qiime commands in qiime2-2020.6.

The current workaround is to run

conda install tensorflow==1.15
conda install songbird -c conda-forge

A fix to the songbird conda-forge recipe will be coming up soon (I hope).