Repository: napari/napari

Issue:
Napari 0.3.4 release crashes when switching to volume rendering
## 🐛 Bug

Napari 0.3.4 (release version) crashes when trying to render volume in 3D.


## To Reproduce

Steps to reproduce the behavior:

1. Load a volume
2. Display and navigate through slices in 2D
3. Switch to 3D -> Crash


![napari_vol_crash](https://user-images.githubusercontent.com/2210044/84094896-3232af00-aa41-11ea-8477-87c4d5257e21.gif)


```
(stardist) λ napari
WARNING: Error drawing visual <Volume at 0x1b6364c0d48>
10:17:55 WARNING Error drawing visual <Volume at 0x1b6364c0d48>
WARNING: Traceback (most recent call last):
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\OpenGL\latebind.py", line 43, in __call__
    return self._finalCall( *args, **named )
TypeError: 'NoneType' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\app\backends\_qt.py", line 825, in paintGL
    self._vispy_canvas.events.draw(region=None)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\util\event.py", line 455, in __call__
    self._invoke_callback(cb, event)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\util\event.py", line 475, in _invoke_callback
    self, cb_event=(cb, event))
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\util\event.py", line 471, in _invoke_callback
    cb(event)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\scene\canvas.py", line 217, in on_draw

    self._draw_scene()
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\scene\canvas.py", line 266, in _draw_scene
    self.draw_visual(self.scene)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\scene\canvas.py", line 304, in draw_visual
    node.draw()
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\scene\visuals.py", line 99, in draw
    self._visual_superclass.draw(self)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\visuals\visual.py", line 443, in draw
    self._vshare.index_buffer)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\visuals\shaders\program.py", line 101, in draw
    Program.draw(self, *args, **kwargs)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\gloo\program.py", line 533, in draw
    canvas.context.flush_commands()
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\gloo\context.py", line 176, in flush_commands
    self.glir.flush(self.shared.parser)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\gloo\glir.py", line 572, in flush
    self._shared.flush(parser)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\gloo\glir.py", line 494, in flush
    parser.parse(self._filter(self.clear(), parser))
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\gloo\glir.py", line 819, in parse
    self._parse(command)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\gloo\glir.py", line 789, in _parse
    ob.set_size(*args)  # Texture[1D, 2D, 3D], RenderBuffer
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\gloo\glir.py", line 1624, in set_size
    gl.GL_BYTE, shape[:3])
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\gloo\glir.py", line 1573, in glTexImage3D
    width, height, depth, border, format, type, None)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\OpenGL\latebind.py", line 47, in __call__
    return self._finalCall( *args, **named )
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\OpenGL\wrapper.py", line 882, in wrapperCall

    result = wrappedOperation( *cArguments )
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\OpenGL\platform\baseplatform.py", line 425, in __call__
    self.__name__, self.__name__,
OpenGL.error.NullFunctionError: Attempt to call an undefined function glTexImage3D, check for bool(glTexImage3D) before calling
10:17:56 WARNING Traceback (most recent call last):
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\OpenGL\latebind.py", line 43, in __call__
    return self._finalCall( *args, **named )
TypeError: 'NoneType' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\app\backends\_qt.py", line 825, in paintGL
    self._vispy_canvas.events.draw(region=None)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\util\event.py", line 455, in __call__
    self._invoke_callback(cb, event)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\util\event.py", line 475, in _invoke_callback
    self, cb_event=(cb, event))
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\util\event.py", line 471, in _invoke_callback
    cb(event)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\scene\canvas.py", line 217, in on_draw

    self._draw_scene()
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\scene\canvas.py", line 266, in _draw_scene
    self.draw_visual(self.scene)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\scene\canvas.py", line 304, in draw_visual
    node.draw()
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\scene\visuals.py", line 99, in draw
    self._visual_superclass.draw(self)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\visuals\visual.py", line 443, in draw
    self._vshare.index_buffer)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\visuals\shaders\program.py", line 101, in draw
    Program.draw(self, *args, **kwargs)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\gloo\program.py", line 533, in draw
    canvas.context.flush_commands()
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\gloo\context.py", line 176, in flush_commands
    self.glir.flush(self.shared.parser)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\gloo\glir.py", line 572, in flush
    self._shared.flush(parser)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\gloo\glir.py", line 494, in flush
    parser.parse(self._filter(self.clear(), parser))
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\gloo\glir.py", line 819, in parse
    self._parse(command)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\gloo\glir.py", line 789, in _parse
    ob.set_size(*args)  # Texture[1D, 2D, 3D], RenderBuffer
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\gloo\glir.py", line 1624, in set_size
    gl.GL_BYTE, shape[:3])
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\vispy\gloo\glir.py", line 1573, in glTexImage3D
    width, height, depth, border, format, type, None)
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\OpenGL\latebind.py", line 47, in __call__
    return self._finalCall( *args, **named )
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\OpenGL\wrapper.py", line 882, in wrapperCall

    result = wrappedOperation( *cArguments )
  File "c:\users\volker\anaconda3\envs\stardist\lib\site-packages\OpenGL\platform\baseplatform.py", line 425, in __call__
    self.__name__, self.__name__,
OpenGL.error.NullFunctionError: Attempt to call an undefined function glTexImage3D, check for bool(glTexImage3D) before calling
```

## Expected behavior

The same volume renders fine in an earlier version of napari.

## Environment

 - Please copy and paste the information at napari info option in help menubar here:
```
napari: 0.3.4
Platform: Windows-10-10.0.18362-SP0
Python: 3.7.7 (default, Apr 15 2020, 05:09:04) [MSC v.1916 64 bit (AMD64)]
Qt: 5.14.2
PyQt5: 5.14.2
NumPy: 1.18.1
SciPy: 1.3.1
Dask: 2.18.0
VisPy: 0.6.4

GL version: 4.6.0 - Build 26.20.100.7812
MAX_TEXTURE_SIZE: 16384

Plugins:
- napari-plugin-engine: 0.1.6
- svg: 0.1.3
```
 This was pip installed into an existing conda environment from the PyPI release.

## Additional context

In the same environment, when I open an IPython console before switching to volume rendering (same volume), **napari does not crash !**

![napari_vol_no_crash](https://user-images.githubusercontent.com/2210044/84094918-3eb70780-aa41-11ea-860b-2bfb174eba83.gif)

Also, the volume renders fine in one of my older napari installations/environments that has the same version of vispy, which rules out my initial thought that this would be a vispy issue. **My current guess is that this may be PyQt-related.** The environment below works. Note a few things are different, notably PySide instead of PyQt.

```
napari: 0.3.1+12.g0cd943c
Platform: Windows-10-10.0.18362-SP0
Python: 3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)]
Qt: 5.14.2
PySide2: 5.14.2.1
NumPy: 1.18.4
SciPy: 1.4.1
Dask: 2.16.0
VisPy: 0.6.4

GL version: 4.6.0 - Build 26.20.100.7812
MAX_TEXTURE_SIZE: 16384

Plugins:
- napari-plugin-engine: 0.1.5
- svg: 0.1.2
```



Discussion:
additional info:
When I start napari from Jupyter in the same enviornment (using `%gui qt` magic) the volume rendering does not crash either.
Can you paste the output of `conda list` for the broken and working environments here?
Hi Talley,

## broken environment

```
(stardist) λ conda list
# packages in environment at C:\Users\Volker\Anaconda3\envs\stardist:
#
# Name                    Version                   Build  Channel
_tflow_select             2.3.0                       mkl
absl-py                   0.9.0            py37hc8dfbb8_1    conda-forge
alabaster                 0.7.12                    <pip>
astor                     0.7.1                      py_0    conda-forge
attrs                     19.3.0                    <pip>
Babel                     2.8.0                     <pip>
backcall                  0.1.0                     <pip>
blas                      1.0                         mkl
bleach                    3.1.4                     <pip>
ca-certificates           2020.4.5.1           hecc5488_0    conda-forge
cachey                    0.2.1                     <pip>
certifi                   2020.4.5.1       py37hc8dfbb8_0    conda-forge
chardet                   3.0.4                     <pip>
colorama                  0.4.3                     <pip>
csbdeep                   0.5.1                     <pip>
cycler                    0.10.0                    <pip>
dask                      2.18.0                    <pip>
decorator                 4.4.2                     <pip>
defusedxml                0.6.0                     <pip>
docutils                  0.16                      <pip>
entrypoints               0.3                       <pip>
freetype-py               2.1.0.post1               <pip>
gast                      0.2.2                      py_0    conda-forge
google-pasta              0.2.0              pyh8c360ce_0    conda-forge
grpcio                    1.23.0           py37h3f65fb1_1    conda-forge
h5py                      2.9.0           nompi_h3cb27cb_1101    conda-forge
hdf5                      1.10.4          nompi_hcc15c50_1106    conda-forge
HeapDict                  1.0.1                     <pip>
icc_rt                    2019.0.0             h0cc432a_1
idna                      2.9                       <pip>
imagecodecs               2020.2.18                 <pip>
imageio                   2.8.0                     <pip>
imagesize                 1.2.0                     <pip>
importlib-metadata        1.6.0                     <pip>
intel-openmp              2019.4                      245
ipykernel                 5.2.1                     <pip>
ipython                   7.13.0                    <pip>
ipython-genutils          0.2.0                     <pip>
ipywidgets                7.5.1                     <pip>
jedi                      0.17.0                    <pip>
Jinja2                    2.11.2                    <pip>
jsonschema                3.2.0                     <pip>
jupyter                   1.0.0                     <pip>
jupyter-client            6.1.3                     <pip>
jupyter-console           6.1.0                     <pip>
jupyter-core              4.6.3                     <pip>
Keras                     2.3.1                     <pip>
keras-applications        1.0.8                      py_1    conda-forge
keras-preprocessing       1.1.0                      py_0    conda-forge
kiwisolver                1.2.0                     <pip>
libblas                   3.8.0                    14_mkl    conda-forge
libcblas                  3.8.0                    14_mkl    conda-forge
liblapack                 3.8.0                    14_mkl    conda-forge
libmklml                  2019.0.5                      0
libprotobuf               3.11.4               h1a1b453_0    conda-forge
llvmlite                  0.31.0                    <pip>
llvmlite                  0.31.0           py37hc8dfbb8_1    conda-forge
m2w64-gcc-libgfortran     5.3.0                         6
m2w64-gcc-libs            5.3.0                         7
m2w64-gcc-libs-core       5.3.0                         7
m2w64-gmp                 6.1.0                         2
m2w64-libwinpthread-git   5.0.0.4634.697f757               2
markdown                  3.2.1                      py_0    conda-forge
MarkupSafe                1.1.1                     <pip>
matplotlib                3.2.1                     <pip>
mistune                   0.8.4                     <pip>
mkl                       2019.4                      245
mkl-service               2.3.0            py37hfa6e2cd_0    conda-forge
msys2-conda-epoch         20160418                      1
napari                    0.3.4                     <pip>
napari-plugin-engine      0.1.6                     <pip>
napari-svg                0.1.3                     <pip>
nbconvert                 5.6.1                     <pip>
nbformat                  5.0.6                     <pip>
networkx                  2.4                       <pip>
notebook                  6.0.3                     <pip>
numba                     0.48.0           py37he350917_0    conda-forge
numpy                     1.18.1           py37h90d3380_1    conda-forge
numpydoc                  1.0.0                     <pip>
openssl                   1.1.1g               he774522_0    conda-forge
opt_einsum                3.2.1                      py_0    conda-forge
packaging                 20.4                      <pip>
pandocfilters             1.4.2                     <pip>
parso                     0.7.0                     <pip>
pickleshare               0.7.5                     <pip>
Pillow                    7.1.2                     <pip>
pip                       20.0.2                   py37_1
prometheus-client         0.7.1                     <pip>
prompt-toolkit            3.0.5                     <pip>
protobuf                  3.11.4           py37h5fe3f0a_1    conda-forge
psutil                    5.7.0                     <pip>
Pygments                  2.6.1                     <pip>
PyOpenGL                  3.1.5                     <pip>
pyparsing                 2.4.7                     <pip>
PyQt5                     5.14.2                    <pip>
PyQt5-sip                 12.8.0                    <pip>
pyreadline                2.1                   py37_1001    conda-forge
pyrsistent                0.16.0                    <pip>
python                    3.7.7                h60c2a47_2
python-dateutil           2.8.1                     <pip>
python_abi                3.7                     1_cp37m    conda-forge
pytz                      2020.1                    <pip>
PyWavelets                1.1.1                     <pip>
pywin32                   227                       <pip>
pywinpty                  0.5.7                     <pip>
PyYAML                    5.3.1                     <pip>
pyzmq                     19.0.0                    <pip>
qtconsole                 4.7.3                     <pip>
QtPy                      1.9.0                     <pip>
requests                  2.23.0                    <pip>
scikit-image              0.16.2                    <pip>
scipy                     1.3.1            py37h29ff71c_0    conda-forge
Send2Trash                1.5.0                     <pip>
setuptools                46.1.3                   py37_0
six                       1.14.0                     py_1    conda-forge
snowballstemmer           2.0.0                     <pip>
Sphinx                    3.1.0                     <pip>
sphinxcontrib-applehelp   1.0.2                     <pip>
sphinxcontrib-devhelp     1.0.2                     <pip>
sphinxcontrib-htmlhelp    1.0.3                     <pip>
sphinxcontrib-jsmath      1.0.1                     <pip>
sphinxcontrib-qthelp      1.0.3                     <pip>
sphinxcontrib-serializinghtml 1.1.4                     <pip>
sqlite                    3.31.1               he774522_0
stardist                  0.5.0                     <pip>
tensorboard               1.15.0                   py37_0    conda-forge
tensorflow                1.15.0          mkl_py37h3789bd0_0
tensorflow-base           1.15.0          mkl_py37h190a33d_0
tensorflow-estimator      1.15.1             pyh2649769_0
termcolor                 1.1.0                      py_2    conda-forge
terminado                 0.8.3                     <pip>
testpath                  0.4.4                     <pip>
tifffile                  2020.2.16                 <pip>
toolz                     0.10.0                    <pip>
tornado                   6.0.4                     <pip>
tqdm                      4.45.0                    <pip>
traitlets                 4.3.3                     <pip>
urllib3                   1.25.9                    <pip>
vc                        14.1                 h0510ff6_4
vispy                     0.6.4                     <pip>
vs2015_runtime            14.16.27012          hf0eaf9b_1
wcwidth                   0.1.9                     <pip>
webencodings              0.5.1                     <pip>
werkzeug                  0.16.1                     py_0    conda-forge
wheel                     0.34.2                   py37_0
widgetsnbextension        3.5.1                     <pip>
wincertstore              0.2                      py37_0
wrapt                     1.12.1           py37h8055547_1    conda-forge
zipp                      3.1.0                     <pip>
zlib                      1.2.11            h2fa13f4_1006    conda-forge
```

## working environmenent 

Despite the name of the environment, this contains an older version of  napari

```
(naparinew) λ conda list
# packages in environment at C:\Users\Volker\Anaconda3\envs\naparinew:
#
# Name                    Version                   Build  Channel
alabaster                 0.7.12                    <pip>
attrs                     19.3.0                    <pip>
Babel                     2.8.0                     <pip>
backcall                  0.1.0                     <pip>
bleach                    3.1.5                     <pip>
ca-certificates           2020.1.1                      0
cachey                    0.2.1                     <pip>
certifi                   2020.4.5.1               py37_0
chardet                   3.0.4                     <pip>
colorama                  0.4.3                     <pip>
cycler                    0.10.0                    <pip>
dask                      2.16.0                    <pip>
decorator                 4.4.2                     <pip>
defusedxml                0.6.0                     <pip>
docutils                  0.16                      <pip>
entrypoints               0.3                       <pip>
fastscript                0.1.4                     <pip>
freetype-py               2.1.0.post1               <pip>
fsspec                    0.7.4                     <pip>
HeapDict                  1.0.1                     <pip>
idna                      2.9                       <pip>
imagecodecs               2020.2.18                 <pip>
imageio                   2.8.0                     <pip>
imagesize                 1.2.0                     <pip>
importlib-metadata        1.6.0                     <pip>
ipykernel                 5.3.0                     <pip>
ipython                   7.14.0                    <pip>
ipython-genutils          0.2.0                     <pip>
ipywidgets                7.5.1                     <pip>
jedi                      0.17.0                    <pip>
Jinja2                    2.11.2                    <pip>
jsonschema                3.2.0                     <pip>
jupyter                   1.0.0                     <pip>
jupyter-client            6.1.3                     <pip>
jupyter-console           6.1.0                     <pip>
jupyter-core              4.6.3                     <pip>
kiwisolver                1.2.0                     <pip>
MarkupSafe                1.1.1                     <pip>
matplotlib                3.2.1                     <pip>
mistune                   0.8.4                     <pip>
napari                    0.3.1+12.g0cd943c           <pip>
napari-plugin-engine      0.1.5                     <pip>
napari-svg                0.1.2                     <pip>
nbconvert                 5.6.1                     <pip>
nbdev                     0.2.18                    <pip>
nbformat                  5.0.6                     <pip>
networkx                  2.4                       <pip>
notebook                  6.0.3                     <pip>
numpy                     1.18.4                    <pip>
numpydoc                  0.9.2                     <pip>
openssl                   1.1.1g               he774522_0
packaging                 20.4                      <pip>
pandocfilters             1.4.2                     <pip>
parso                     0.7.0                     <pip>
pickleshare               0.7.5                     <pip>
Pillow                    7.1.2                     <pip>
pip                       20.0.2                   py37_3
prometheus-client         0.7.1                     <pip>
prompt-toolkit            3.0.5                     <pip>
psutil                    5.7.0                     <pip>
Pygments                  2.6.1                     <pip>
PyOpenGL                  3.1.5                     <pip>
pyparsing                 2.4.7                     <pip>
pyrsistent                0.16.0                    <pip>
PySide2                   5.14.2.1                  <pip>
python                    3.7.7                h81c818b_4
python-dateutil           2.8.1                     <pip>
pytz                      2020.1                    <pip>
PyWavelets                1.1.1                     <pip>
pywin32                   227                       <pip>
pywinpty                  0.5.7                     <pip>
PyYAML                    5.3.1                     <pip>
pyzmq                     19.0.1                    <pip>
qtconsole                 4.7.4                     <pip>
QtPy                      1.9.0                     <pip>
requests                  2.23.0                    <pip>
scikit-image              0.17.2                    <pip>
scipy                     1.4.1                     <pip>
Send2Trash                1.5.0                     <pip>
setuptools                46.4.0                   py37_0
shiboken2                 5.14.2.1                  <pip>
six                       1.15.0                    <pip>
snowballstemmer           2.0.0                     <pip>
Sphinx                    3.0.3                     <pip>
sphinxcontrib-applehelp   1.0.2                     <pip>
sphinxcontrib-devhelp     1.0.2                     <pip>
sphinxcontrib-htmlhelp    1.0.3                     <pip>
sphinxcontrib-jsmath      1.0.1                     <pip>
sphinxcontrib-qthelp      1.0.3                     <pip>
sphinxcontrib-serializinghtml 1.1.4                     <pip>
sqlite                    3.31.1               h2a8f88b_1
terminado                 0.8.3                     <pip>
testpath                  0.4.4                     <pip>
tifffile                  2020.5.11                 <pip>
toolz                     0.10.0                    <pip>
tornado                   6.0.4                     <pip>
traitlets                 4.3.3                     <pip>
urllib3                   1.25.9                    <pip>
vc                        14.1                 h0510ff6_4
vispy                     0.6.4                     <pip>
vs2015_runtime            14.16.27012          hf0eaf9b_1
wcwidth                   0.1.9                     <pip>
webencodings              0.5.1                     <pip>
wheel                     0.34.2                   py37_0
widgetsnbextension        3.5.1                     <pip>
wincertstore              0.2                      py37_0
wrapt                     1.12.1                    <pip>
zipp                      3.1.0                     <pip>
zlib                      1.2.11               h62dcd97_4
```
`vispy` and `PyOpenGL` where one might expect the error based on the traceback are identical in both environments. I had a cursory look into the `PyOpenGL` but I would have to spend a lot more time trying to understand the latebind-machinery that is being used there.
But the underlying difference seems to be something about the Qt context, maybe some way that Qt does or does not initialize certain OpenGL features (this is a very superficial guess).
@VolkerH 

(a) Can you reproduce this bug in a brand new environment with `pip install napari[all]`? If not, can you start adding packages from your "broken" env one by one to see if you can get it to break?
(b) Can you share the dataset causing the crash? If not, can you reproduce the crash with a synthetic (random) volume?
On my system, this crashes with `OpenGL.error.NullFunctionError` every time when toggling the number of displayed dimensions:
```Python
import numpy
import napari
data = numpy.zeros((1, 1), 'u1')
with napari.gui_qt():
    napari.view_image(data)
```

This does not crash:
```Python
import numpy
import napari
data = numpy.zeros((1, 1), 'u1')
with napari.gui_qt():
    viewer = napari.Viewer()
    viewer.add_image(data)
```

```
napari: 0.3.4
Platform: Windows-10-10.0.19041-SP0
Python: 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)]
Qt: 5.14.2
PyQt5: 5.14.2
NumPy: 1.18.5
SciPy: 1.4.1
Dask: 2.18.1
VisPy: 0.6.4

GL version: 4.6.0 NVIDIA 442.05
MAX_TEXTURE_SIZE: 32768

Plugins:
- napari-plugin-engine: 0.1.6
- svg: 0.1.3
```
This looks similar to this what I report on zulip. But in my case crash is not always, but depends which file I load. And if I firs load one which is not crashing napari, then I cal load crasing one and it works. 

Reverting #1250 "solves" the issue for me. 
Fascinating.  Maybe i removed the “magical mysterious goodness” too soon.  @cgohlke, any possible theories as to what’s going on here?
Hi,

@jni , I can reproduce this in a clean environment. 

```
conda create -n crashtest python=3.7
conda activate crashtest
pip install napari[all]
```

This is sufficient to reproduce the crash.
Here is the link to the data set (this is just to be used for debugging not as sample images etc.)
https://www.dropbox.com/s/ycyhhjxej38gjw1/stack.tif?dl=0

Edited to add:

Just looked at #1250 ... indeed fascinating. 
@VolkerH, if you add `from scipy import stats` to `napari.__init__.py` after pip installing, or cloning from master, does it solve it for you as well?
Yes, after adding the import as suggested it no longer crashes for that volume.
unbelievable!  I wish we could give something like a stack overflow bounty to whoever can figure out what it is in `scipy.stats` that is (likely indirectly) helping out here.  in the meantime, I suppose we can just add it back?
> in the meantime, I suppose we can just add it back?

Yep, let's go for it! Maybe @cgohlke's minimal example can make a failing test on our CI? 🤞 
@VolkerH would you mind adding a file `napari/_tests/test_magic_import.py` with the contents:

```python
def test_viewer_crash(qtbot):
    import numpy
    import napari
    data = numpy.zeros((1, 1), 'u1')
    with napari.gui_qt():
        v = napari.view_image(data)
        v.dims.ndisplay = 3
    v.close()
```

and running it with pytest? I'd like to know whether this is something we can test for...

**Edit:** Added qtbot and v.close().

The code snippet in the test does **not** crash napari in my enviornment (I confirmed that I removed the `scipy.stats` import before trying this).

Resolving patch:
diff --git a/napari/__init__.py b/napari/__init__.py
--- a/napari/__init__.py
+++ b/napari/__init__.py
@@ -75,5 +75,14 @@
 # register napari object types with magicgui if it is installed
 _magicgui.register_types_with_magicgui()
 
+
+# this unused import is here to fix a very strange bug.
+# there is some mysterious magical goodness in scipy stats that needs
+# to be imported early.
+# see: https://github.com/napari/napari/issues/925
+# see: https://github.com/napari/napari/issues/1347
+from scipy import stats  # noqa: F401
+
 del _magicgui
+del stats
 del _viewer_key_bindings


Test patch: