Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Sur, problem importing navis #17

Closed
ASiliciano opened this issue Jan 15, 2021 · 3 comments
Closed

Bug Sur, problem importing navis #17

ASiliciano opened this issue Jan 15, 2021 · 3 comments

Comments

@ASiliciano
Copy link

With import navis, I can't seem to import vispy, since upgrading to Big Sur (see: vispy/vispy#1885). This hasn't been fixed yet, even with python 3.9.1. I'm mostly using notebooks, and therefore don't require vispy. Any workaround for this until it's fixed to use navis without vispy? Thanks!

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-78772b4632e1> in <module>
----> 1 import navis
      2 import numpy as np
      3 import pandas as pd
      4 import networkx as nx
      5 import matplotlib.pyplot as plt

/opt/anaconda3/envs/navis/lib/python3.9/site-packages/navis/__init__.py in <module>
     16 from .core import *
     17 from .data import *
---> 18 from .clustering import *
     19 from .connectivity import *
     20 from .graph import *

/opt/anaconda3/envs/navis/lib/python3.9/site-packages/navis/clustering/__init__.py in <module>
     12 #    GNU General Public License for more details.
     13 
---> 14 from .cluster import (cluster_by_connectivity, cluster_by_synapse_placement,
     15                       cluster_xyz, ClustResults)
     16 

/opt/anaconda3/envs/navis/lib/python3.9/site-packages/navis/clustering/cluster.py in <module>
     28 from ..core.neurons import TreeNeuron
     29 from ..core.neuronlist import NeuronList
---> 30 from .. import plotting, utils, config
     31 
     32 # Set up logging

/opt/anaconda3/envs/navis/lib/python3.9/site-packages/navis/plotting/__init__.py in <module>
     13 
     14 from .d import *
---> 15 from .dd import *
     16 from .ddd import *
     17 from .vispy import *

/opt/anaconda3/envs/navis/lib/python3.9/site-packages/navis/plotting/dd.py in <module>
     35 from .. import utils, config, core
     36 from .colors import prepare_colormap, vertex_colors
---> 37 from .plot_utils import segments_to_coords, tn_pairs_to_coords
     38 
     39 __all__ = ['plot2d']

/opt/anaconda3/envs/navis/lib/python3.9/site-packages/navis/plotting/plot_utils.py in <module>
     30 with warnings.catch_warnings():
     31     warnings.simplefilter("ignore")
---> 32     from vispy.util.transforms import rotate
     33 
     34 __all__ = ['tn_pairs_to_coords', 'segments_to_coords', 'fibonacci_sphere', 'make_tube']

/opt/anaconda3/envs/navis/lib/python3.9/site-packages/vispy/__init__.py in <module>
     28     pass
     29 
---> 30 from .util import config, set_log_level, keys, sys_info  # noqa
     31 from .util.wrappers import use, test  # noqa
     32 # load the two functions that IPython uses to instantiate an extension

/opt/anaconda3/envs/navis/lib/python3.9/site-packages/vispy/util/__init__.py in <module>
     12 from .fetching import load_data_file  # noqa
     13 from .frozen import Frozen  # noqa
---> 14 from . import fonts       # noqa
     15 from . import transforms  # noqa
     16 from .wrappers import use, run_subprocess  # noqa

/opt/anaconda3/envs/navis/lib/python3.9/site-packages/vispy/util/fonts/__init__.py in <module>
     11 __all__ = ['list_fonts']
     12 
---> 13 from ._triage import _load_glyph, list_fonts  # noqa, analysis:ignore
     14 from ._vispy_fonts import _vispy_fonts  # noqa, analysis:ignore

/opt/anaconda3/envs/navis/lib/python3.9/site-packages/vispy/util/fonts/_triage.py in <module>
     12     from ...ext.fontconfig import _list_fonts
     13 elif sys.platform == 'darwin':
---> 14     from ._quartz import _load_glyph, _list_fonts
     15 elif sys.platform.startswith('win'):
     16     from ._freetype import _load_glyph  # noqa, analysis:ignore

/opt/anaconda3/envs/navis/lib/python3.9/site-packages/vispy/util/fonts/_quartz.py in <module>
     10 from ctypes import byref, c_int32, c_byte
     11 
---> 12 from ...ext.cocoapy import cf, ct, quartz, CFRange, CFSTR, CGGlyph, UniChar, \
     13     kCTFontFamilyNameAttribute, kCTFontBoldTrait, kCTFontItalicTrait, \
     14     kCTFontSymbolicTrait, kCTFontTraitsAttribute, kCTFontAttributeName, \

/opt/anaconda3/envs/navis/lib/python3.9/site-packages/vispy/ext/cocoapy.py in <module>
   1124 
   1125 NSDefaultRunLoopMode = c_void_p.in_dll(appkit, 'NSDefaultRunLoopMode')
-> 1126 NSEventTrackingRunLoopMode = c_void_p.in_dll(
   1127     appkit, 'NSEventTrackingRunLoopMode')
   1128 NSApplicationDidHideNotification = c_void_p.in_dll(

ValueError: dlsym(RTLD_DEFAULT, NSEventTrackingRunLoopMode): symbol not found
@schlegelp
Copy link
Collaborator

I've seen that issue. Will think about a way to catch this specific issue but in the meantime you could try to mock vispy before importing navis?

@schlegelp
Copy link
Collaborator

schlegelp commented Jan 18, 2021

I finally had time to try this myself. This is a bit hacky it but it should let you import and work with navis (minus vispy plotting obviously):

import sys
from unittest.mock import MagicMock

# Mock vispy and relevant submodules
sys.modules['vispy'] = MagicMock()
sys.modules['vispy.util'] = MagicMock()
sys.modules['vispy.gloo'] = MagicMock()
sys.modules['vispy.gloo.util'] = MagicMock()
sys.modules['vispy.util.transforms'] = MagicMock()
sys.modules['vispy.util.quaternion'] = MagicMock()
sys.modules['vispy.geometry'] = MagicMock()

# Now you should be able to import navis
import navis

@ASiliciano
Copy link
Author

Thanks, this works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants