dyneusr icon indicating copy to clipboard operation
dyneusr copied to clipboard

Problem importing dyneusr; matplotlib TkAgg backend

Open jsmentch opened this issue 5 years ago • 8 comments

I've been trying to install dyneusr on a singularity image and cannot import it in python. I seem to be having an issue with matplotlib backend TkAgg. I installed using pip after installing the dependencies and this is on debian stretch. Have you come across this problem or know a possible solution? Thanks!

I have tried restarting the kernel and importing before anything else. I've also tried downgrading to matplotlib 3.0.3. These were the only solutions I could find online.

Here is the error I receive after trying to import dyneusr:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/miniconda-latest/envs/neuro/lib/python3.7/site-packages/dyneusr/__init__.py", line 18, in <module>
    from . import tools
  File "/opt/miniconda-latest/envs/neuro/lib/python3.7/site-packages/dyneusr/tools/__init__.py", line 8, in <module>
    from . import mixture
  File "/opt/miniconda-latest/envs/neuro/lib/python3.7/site-packages/dyneusr/tools/mixture.py", line 23, in <module>
    mpl.use('TkAgg', warn=False)
  File "/opt/miniconda-latest/envs/neuro/lib/python3.7/site-packages/matplotlib/__init__.py", line 1391, in use
    switch_backend(name)
  File "/opt/miniconda-latest/envs/neuro/lib/python3.7/site-packages/matplotlib/pyplot.py", line 222, in switch_backend
    newbackend, required_framework, current_framework))
ImportError: Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'headless' is currently running

jsmentch avatar Mar 24 '20 20:03 jsmentch

@jsmentch, thanks for reporting!

definitely looks familiar, and pretty sure it is due to some lazy coding on my part

sorry for the delay, but should have this resolved for you ASAP

calebgeniesse avatar Mar 27 '20 05:03 calebgeniesse

removing all the calls to matplotlib.use should get rid of the errors (see #9)

calebgeniesse avatar Mar 27 '20 06:03 calebgeniesse

went ahead and merged the relevant changes into master with pull request #9

@jsmentch, hope this does the trick, but let me know if you have any other problems!

calebgeniesse avatar Mar 27 '20 06:03 calebgeniesse

That worked, I can now run the sample notebooks with no issues, thank you!!

I'm still having trouble installing it in a singularity recipe but that is unrelated and on my end w/ github/singularity/neurodocker and for now can work around this. Thanks again.

jsmentch avatar Mar 31 '20 19:03 jsmentch

@jsmentch Awesome, thanks for letting me know.

I am not too familiar with singularity/docker/etc, but let me know if there's anything else I can do to help!

And if you (or anyone from the future) figure out how to setup a container, feel free to share/contribute your findings (i.e., see Issue #1, or submit a new pull request)

calebgeniesse avatar Mar 31 '20 21:03 calebgeniesse

If there is an updated simple pip install or conda install version released online sometime then I may be able to create a container using neurodocker for that release.

As I learn how to use containers if I'm able to do that or install from source I will make a pull request

jsmentch avatar Mar 31 '20 22:03 jsmentch

Not sure what neurodocker expects, but technically, you can run

pip install git+git://github.com/braindynamicslab/dyneusr.git

Otherwise, I will try to push an updated build to pypi.org as soon as possible.

And that'd be great, thanks!

calebgeniesse avatar Mar 31 '20 22:03 calebgeniesse

@jsmentch, just uploaded the latest build, dyneusr==0.3.5!

https://pypi.org/project/dyneusr/

let me know if you have any problems

calebgeniesse avatar Apr 01 '20 00:04 calebgeniesse