question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pip install napari[all] doesn't work on Windows (pywin32 conflict between conda and pip)

See original GitHub issue

🐛 Bug

Hi all,

following up on a discussion on image.sc I’m trying some napari installations on windows which fail regularily. Napari crashes right after installation in this case.

To Reproduce

Steps to reproduce the behavior:

open a cmd terminal on Windows 10 and enter these commands:

conda create --name test_1 python=3.8
conda activate test_1
pip install napari[all]
napari

This error shows up:

Traceback (most recent call last):
  File "C:\Users\rober\miniconda3\envs\test_1\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\rober\miniconda3\envs\test_1\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\rober\miniconda3\envs\test_1\Scripts\napari.exe\__main__.py", line 7, in <module>
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\__main__.py", line 431, in main
    _run()
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\__main__.py", line 230, in _run
    from napari import run, view_path
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\_lazy.py", line 47, in __getattr__
    submod = import_module(f'{module_name}.{attr_to_modules[name]}')
  File "C:\Users\rober\miniconda3\envs\test_1\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\view_layers.py", line 17, in <module>
    from .viewer import Viewer
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\viewer.py", line 5, in <module>
    from .components.viewer_model import ViewerModel
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\components\__init__.py", line 17, in <module>
    from .camera import Camera
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\components\camera.py", line 6, in <module>
    from ..utils.events import EventedModel
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\utils\__init__.py", line 2, in <module>
    from .colormaps import Colormap
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\utils\colormaps\__init__.py", line 2, in <module>
    from .colormap import Colormap
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\utils\colormaps\colormap.py", line 7, in <module>
    from ..events import EventedModel
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\utils\events\__init__.py", line 1, in <module>
    from .event import EmitterGroup, Event, EventEmitter  # isort:skip
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\utils\events\event.py", line 71, in <module>
    from ..translations import trans
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\utils\translations.py", line 14, in <module>
    from ._base import _DEFAULT_CONFIG_PATH, _DEFAULT_LOCALE
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\utils\_base.py", line 14, in <module>
    _DEFAULT_CONFIG_PATH = user_config_dir(_APPNAME, _APPAUTHOR, _FILENAME)
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\appdirs.py", line 196, in user_config_dir
    path = user_data_dir(appname, appauthor, None, roaming)
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\appdirs.py", line 81, in user_data_dir
    path = os.path.normpath(_get_win_folder(const))
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\appdirs.py", line 480, in _get_win_folder_with_pywin32
    from win32com.shell import shellcon, shell
ImportError: DLL load failed while importing shell: The specified procedure could not be found.

Expected behavior

Would be cool to understand what’s going on here and add a hint to an FAQ/troublshooting section on the napari website. This error is quite common in our institute. We use conda install napari nowadays to prevent it.

Environment

conda list:

# Name                    Version                   Build  Channel
alabaster                 0.7.12                   pypi_0    pypi
appdirs                   1.4.4                    pypi_0    pypi
attrs                     21.2.0                   pypi_0    pypi
babel                     2.9.1                    pypi_0    pypi
backcall                  0.2.0                    pypi_0    pypi
ca-certificates           2021.10.8            h5b45459_0    conda-forge
cachey                    0.2.1                    pypi_0    pypi
certifi                   2021.10.8                pypi_0    pypi
charset-normalizer        2.0.7                    pypi_0    pypi
cloudpickle               2.0.0                    pypi_0    pypi
colorama                  0.4.4                    pypi_0    pypi
cycler                    0.11.0                   pypi_0    pypi
dask                      2021.11.1                pypi_0    pypi
debugpy                   1.5.1                    pypi_0    pypi
decorator                 5.1.0                    pypi_0    pypi
docstring-parser          0.13                     pypi_0    pypi
docutils                  0.17.1                   pypi_0    pypi
entrypoints               0.3                      pypi_0    pypi
fonttools                 4.28.1                   pypi_0    pypi
freetype-py               2.2.0                    pypi_0    pypi
fsspec                    2021.11.0                pypi_0    pypi
heapdict                  1.0.1                    pypi_0    pypi
hsluv                     5.0.2                    pypi_0    pypi
idna                      3.3                      pypi_0    pypi
imageio                   2.10.5                   pypi_0    pypi
imagesize                 1.3.0                    pypi_0    pypi
importlib-resources       5.4.0                    pypi_0    pypi
ipykernel                 6.5.0                    pypi_0    pypi
ipython                   7.29.0                   pypi_0    pypi
ipython-genutils          0.2.0                    pypi_0    pypi
jedi                      0.18.1                   pypi_0    pypi
jinja2                    3.0.3                    pypi_0    pypi
jsonschema                4.2.1                    pypi_0    pypi
jupyter-client            7.0.6                    pypi_0    pypi
jupyter-core              4.9.1                    pypi_0    pypi
kiwisolver                1.3.2                    pypi_0    pypi
locket                    0.2.1                    pypi_0    pypi
magicgui                  0.3.3                    pypi_0    pypi
markupsafe                2.0.1                    pypi_0    pypi
matplotlib                3.5.0                    pypi_0    pypi
matplotlib-inline         0.1.3                    pypi_0    pypi
napari                    0.4.12                   pypi_0    pypi
napari-console            0.0.4                    pypi_0    pypi
napari-plugin-engine      0.2.0                    pypi_0    pypi
napari-svg                0.1.5                    pypi_0    pypi
nest-asyncio              1.5.1                    pypi_0    pypi
networkx                  2.6.3                    pypi_0    pypi
numpy                     1.21.4                   pypi_0    pypi
numpydoc                  1.1.0                    pypi_0    pypi
openssl                   3.0.0                h8ffe710_2    conda-forge
packaging                 21.2                     pypi_0    pypi
parso                     0.8.2                    pypi_0    pypi
partd                     1.2.0                    pypi_0    pypi
pickleshare               0.7.5                    pypi_0    pypi
pillow                    8.4.0                    pypi_0    pypi
pint                      0.18                     pypi_0    pypi
pip                       21.3.1             pyhd8ed1ab_0    conda-forge
pooch                     1.5.2                    pypi_0    pypi
prompt-toolkit            3.0.22                   pypi_0    pypi
psutil                    5.8.0                    pypi_0    pypi
psygnal                   0.2.0                    pypi_0    pypi
pydantic                  1.8.2                    pypi_0    pypi
pygments                  2.10.0                   pypi_0    pypi
pyopengl                  3.1.5                    pypi_0    pypi
pyparsing                 2.4.7                    pypi_0    pypi
pyqt5                     5.15.6                   pypi_0    pypi
pyqt5-qt5                 5.15.2                   pypi_0    pypi
pyqt5-sip                 12.9.0                   pypi_0    pypi
pyrsistent                0.18.0                   pypi_0    pypi
python                    3.8.12          h900ac77_2_cpython    conda-forge
python-dateutil           2.8.2                    pypi_0    pypi
python_abi                3.8                      2_cp38    conda-forge
pytz                      2021.3                   pypi_0    pypi
pywavelets                1.2.0                    pypi_0    pypi
pywin32                   302                      pypi_0    pypi
pyyaml                    6.0                      pypi_0    pypi
pyzmq                     22.3.0                   pypi_0    pypi
qtconsole                 5.2.0                    pypi_0    pypi
qtpy                      1.11.2                   pypi_0    pypi
requests                  2.26.0                   pypi_0    pypi
scikit-image              0.18.3                   pypi_0    pypi
scipy                     1.7.2                    pypi_0    pypi
setuptools                59.1.1           py38haa244fe_0    conda-forge
setuptools-scm            6.3.2                    pypi_0    pypi
six                       1.16.0                   pypi_0    pypi
snowballstemmer           2.2.0                    pypi_0    pypi
sphinx                    4.3.0                    pypi_0    pypi
sphinxcontrib-applehelp   1.0.2                    pypi_0    pypi
sphinxcontrib-devhelp     1.0.2                    pypi_0    pypi
sphinxcontrib-htmlhelp    2.0.0                    pypi_0    pypi
sphinxcontrib-jsmath      1.0.1                    pypi_0    pypi
sphinxcontrib-qthelp      1.0.3                    pypi_0    pypi
sphinxcontrib-serializinghtml 1.1.5                    pypi_0    pypi
sqlite                    3.36.0               h8ffe710_2    conda-forge
superqt                   0.2.4                    pypi_0    pypi
tifffile                  2021.11.2                pypi_0    pypi
tomli                     1.2.2                    pypi_0    pypi
toolz                     0.11.2                   pypi_0    pypi
tornado                   6.1                      pypi_0    pypi
tqdm                      4.62.3                   pypi_0    pypi
traitlets                 5.1.1                    pypi_0    pypi
typing-extensions         4.0.0                    pypi_0    pypi
ucrt                      10.0.20348.0         h57928b3_0    conda-forge
urllib3                   1.26.7                   pypi_0    pypi
vc                        14.2                 hb210afc_5    conda-forge
vispy                     0.9.3                    pypi_0    pypi
vs2015_runtime            14.29.30037          h902a5da_5    conda-forge
wcwidth                   0.2.5                    pypi_0    pypi
wheel                     0.37.0             pyhd8ed1ab_1    conda-forge
wrapt                     1.13.3                   pypi_0    pypi

pip list:

Package                       Version
----------------------------- ---------
alabaster                     0.7.12
appdirs                       1.4.4
attrs                         21.2.0
Babel                         2.9.1
backcall                      0.2.0
bleach                        4.1.0
cachey                        0.2.1
certifi                       2021.10.8
charset-normalizer            2.0.7
cloudpickle                   2.0.0
colorama                      0.4.4
cycler                        0.11.0
dask                          2021.11.1
debugpy                       1.5.1
decorator                     5.1.0
docstring-parser              0.13
docutils                      0.17.1
entrypoints                   0.3
fonttools                     4.28.1
freetype-py                   2.2.0
fsspec                        2021.11.0
HeapDict                      1.0.1
hsluv                         5.0.2
idna                          3.3
imageio                       2.10.5
imagesize                     1.3.0
importlib-metadata            4.6.0
importlib-resources           5.4.0
ipykernel                     6.5.0
ipython                       7.29.0
ipython-genutils              0.2.0
jedi                          0.18.1
Jinja2                        3.0.3
jsonschema                    4.2.1
jupyter-client                7.0.6
jupyter-core                  4.9.1
keyring                       23.0.1
kiwisolver                    1.3.2
locket                        0.2.1
magicgui                      0.3.3
MarkupSafe                    2.0.1
matplotlib                    3.5.0
matplotlib-inline             0.1.3
napari                        0.4.12
napari-console                0.0.4
napari-plugin-engine          0.2.0
napari-svg                    0.1.5
nest-asyncio                  1.5.1
networkx                      2.6.3
numpy                         1.21.4
numpydoc                      1.1.0
packaging                     21.2
parso                         0.8.2
partd                         1.2.0
pickleshare                   0.7.5
Pillow                        8.4.0
Pint                          0.18
pip                           21.3.1
pkginfo                       1.7.0
pooch                         1.5.2
prompt-toolkit                3.0.22
psutil                        5.8.0
psygnal                       0.2.0
pydantic                      1.8.2
Pygments                      2.10.0
PyOpenGL                      3.1.5
pyparsing                     2.4.7
PyQt5                         5.15.6
PyQt5-Qt5                     5.15.2
PyQt5-sip                     12.9.0
pyrsistent                    0.18.0
python-dateutil               2.8.2
pytz                          2021.3
PyWavelets                    1.2.0
pywin32                       302
pywin32-ctypes                0.2.0
PyYAML                        6.0
pyzmq                         22.3.0
qtconsole                     5.2.0
QtPy                          1.11.2
readme-renderer               29.0
requests                      2.26.0
requests-toolbelt             0.9.1
rfc3986                       1.5.0
scikit-image                  0.18.3
scipy                         1.7.2
setuptools                    58.2.0
setuptools-scm                6.3.2
six                           1.16.0
snowballstemmer               2.2.0
Sphinx                        4.3.0
sphinxcontrib-applehelp       1.0.2
sphinxcontrib-devhelp         1.0.2
sphinxcontrib-htmlhelp        2.0.0
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.3
sphinxcontrib-serializinghtml 1.1.5
superqt                       0.2.4
tifffile                      2021.11.2
tomli                         1.2.2
toolz                         0.11.2
tornado                       6.1
tqdm                          4.62.3
traitlets                     5.1.1
twine                         3.4.2
typing_extensions             4.0.0
urllib3                       1.26.7
vispy                         0.9.3
wcwidth                       0.2.5
webencodings                  0.5.1
wheel                         0.37.0
wrapt                         1.13.3
zipp                          3.4.1

Additional context

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
haesleinhuepfcommented, Nov 17, 2021

maybe, for fun, try conda uninstall pywin32 in your base?

I just tried. In my test_1 environment napari still doesn’t work then, same error:

Traceback (most recent call last):
  File "C:\Users\rober\miniconda3\envs\test_1\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\rober\miniconda3\envs\test_1\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\rober\miniconda3\envs\test_1\Scripts\napari.exe\__main__.py", line 7, in <module>
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\__main__.py", line 431, in main
    _run()
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\__main__.py", line 230, in _run
    from napari import run, view_path
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\_lazy.py", line 47, in __getattr__
    submod = import_module(f'{module_name}.{attr_to_modules[name]}')
  File "C:\Users\rober\miniconda3\envs\test_1\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\view_layers.py", line 17, in <module>
    from .viewer import Viewer
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\viewer.py", line 5, in <module>
    from .components.viewer_model import ViewerModel
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\components\__init__.py", line 17, in <module>
    from .camera import Camera
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\components\camera.py", line 6, in <module>
    from ..utils.events import EventedModel
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\utils\__init__.py", line 2, in <module>
    from .colormaps import Colormap
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\utils\colormaps\__init__.py", line 2, in <module>
    from .colormap import Colormap
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\utils\colormaps\colormap.py", line 7, in <module>
    from ..events import EventedModel
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\utils\events\__init__.py", line 1, in <module>
    from .event import EmitterGroup, Event, EventEmitter  # isort:skip
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\utils\events\event.py", line 71, in <module>
    from ..translations import trans
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\utils\translations.py", line 14, in <module>
    from ._base import _DEFAULT_CONFIG_PATH, _DEFAULT_LOCALE
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\napari\utils\_base.py", line 14, in <module>
    _DEFAULT_CONFIG_PATH = user_config_dir(_APPNAME, _APPAUTHOR, _FILENAME)
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\appdirs.py", line 196, in user_config_dir
    path = user_data_dir(appname, appauthor, None, roaming)
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\appdirs.py", line 81, in user_data_dir
    path = os.path.normpath(_get_win_folder(const))
  File "C:\Users\rober\miniconda3\envs\test_1\lib\site-packages\appdirs.py", line 480, in _get_win_folder_with_pywin32
    from win32com.shell import shellcon, shell
ImportError: DLL load failed while importing shell: The specified procedure could not be found.

BUT: After conda install pywin32 inside test_1, napari works again! 🥳

I will close this issue. Thanks 💯 for your help!

1reaction
tlambert03commented, Nov 17, 2021

I’ll also note that all of those things (which are just the requirements for twine) are not in your conda env… so they might be in some global user space (i.e. if you have ever used pip install --user ...) I have no particular reason to suspect that any of those things are the problem, and if I install twine into my environment it brings pywin32-ctypes, and it still works for me (though my appdirs is still using not using the pywin32 version of _get_win_dir). So, see if you can figure out where that win32api module is on your computer:

import win32api
win32api.__file__
Read more comments on GitHub >

github_iconTop Results From Across the Web

do PIP and Conda have conflicts? - Stack Overflow
I tried pip for some packages due to the smallness of conda's repository and I found no problem using both together. I'm using...
Read more >
Setup.py for plugin that depends on pyclesperato - Development
The problem I had was specific to the pip setup.py file. The installation of pyopencl seems to work smoothly with conda but not...
Read more >
Installation guide — Scrapy 1.0.7 documentation
For Windows users, or if you have issues installing through pip , this is the recommended way to install Scrapy. If you already...
Read more >
Installation — xlwings dev documentation
If you are new to Python or have trouble installing xlwings, Anaconda is highly recommended. Otherwise you can also install it manually with...
Read more >
Understanding Conda and Pip - Anaconda
Conda on the other hand can install Python packages as well as the Python interpreter directly. Another key difference between the two tools...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found