conda-forge / pillow-feedstock

A conda-smithy repository for pillow.
BSD 3-Clause "New" or "Revised" License
2 stars 30 forks source link

DLL import fails in fresh conda install #66

Closed AndreusUltimus closed 4 years ago

AndreusUltimus commented 4 years ago

Issue:

Very simple, fresh conda install of pillow gets a DLL error.

These instructions (from this issue: https://github.com/conda-forge/pillow-feedstock/issues/45) get an error.

conda create --name TEST --channel conda-forge pillow wordcloud
conda activate TEST
python -c "import  wordcloud; print(wordcloud.__version__)"

  File "<string>", line 1, in <module>
  File "C:\Apps\Miniconda3\envs\TEST\lib\site-packages\wordcloud\__init__.py", line 1, in <module>
    from .wordcloud import (WordCloud, STOPWORDS, random_color_func,
  File "C:\Apps\Miniconda3\envs\TEST\lib\site-packages\wordcloud\wordcloud.py", line 19, in <module>
    from PIL import Image
  File "C:\Apps\Miniconda3\envs\TEST\lib\site-packages\PIL\Image.py", line 90, in <module>
    from . import _imaging as core
ImportError: DLL load failed while importing _imaging: The specified module could not be found.

This workaround succeeds, but of course creates other problems with environment repackaging.

conda uninstall pillow
pip install pillow


Environment (conda list):

``` $ conda list # packages in environment at C:\Apps\Miniconda3\envs\TEST: # # Name Version Build Channel ca-certificates 2019.9.11 hecc5488_0 conda-forge certifi 2019.9.11 py38_0 conda-forge freetype 2.10.0 h563cfd7_1 conda-forge intel-openmp 2019.4 245 jpeg 9c hfa6e2cd_1001 conda-forge libblas 3.8.0 14_mkl conda-forge libcblas 3.8.0 14_mkl conda-forge liblapack 3.8.0 14_mkl conda-forge libpng 1.6.37 h7602738_0 conda-forge libtiff 4.1.0 h2e92f26_0 conda-forge lz4-c 1.8.3 he025d50_1001 conda-forge mkl 2019.4 245 numpy 1.17.3 py38hc71023c_0 conda-forge olefile 0.46 py_0 conda-forge openssl 1.1.1c hfa6e2cd_0 conda-forge pillow 6.2.1 py38h643dfcc_0 conda-forge pip 19.3.1 py38_0 conda-forge python 3.8.0 hc9e8b01_2 conda-forge setuptools 41.6.0 py38_1 conda-forge sqlite 3.30.1 hfa6e2cd_0 conda-forge tk 8.6.9 hfa6e2cd_1003 conda-forge vc 14.1 h0510ff6_4 vs2015_runtime 14.16.27012 hf0eaf9b_0 wheel 0.33.6 py38_0 conda-forge wincertstore 0.2 py38_1003 conda-forge wordcloud 1.5.0 py38hfa6e2cd_1000 conda-forge xz 5.2.4 h2fa13f4_1001 conda-forge zlib 1.2.11 h2fa13f4_1006 conda-forge zstd 1.4.3 hd8a0e53_0 conda-forge ```


Details about conda and system ( conda info ):

``` $ conda info active environment : TEST active env location : C:\Apps\Miniconda3\envs\TEST shell level : 3 user config file : C:\Users\\.condarc populated config files : C:\Users\\.condarc conda version : 4.7.12 conda-build version : not installed python version : 3.7.4.final.0 virtual packages : __cuda=9.1 base environment : C:\Apps\Miniconda3 (writable) channel URLs : https://conda.anaconda.org/conda-forge/win-64 https://conda.anaconda.org/conda-forge/noarch https://repo.anaconda.com/pkgs/main/win-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/win-64 https://repo.anaconda.com/pkgs/r/noarch https://repo.anaconda.com/pkgs/msys2/win-64 https://repo.anaconda.com/pkgs/msys2/noarch package cache : C:\Apps\Miniconda3\pkgs C:\Users\\.conda\pkgs C:\Users\\AppData\Local\conda\conda\pkgs envs directories : C:\Apps\Miniconda3\envs C:\Users\\.conda\envs C:\Users\\AppData\Local\conda\conda\envs platform : win-64 user-agent : conda/4.7.12 requests/2.22.0 CPython/3.7.4 Windows/10 Windows/10.0.18362 administrator : False netrc file : None offline mode : False ```
DancingQuanta commented 4 years ago

I am having same issues, roughly around the same time as OP which started when I am updating my conda env. I tried this workaround

conda uninstall pillow --force-remove
pip install pillow

without any success. I used --force-remove to prevent other libraries dependent on pillow from being removed.

mcs07 commented 4 years ago

The pip install workaround worked for me.

I wonder is there anything we can learn from https://github.com/python-pillow/Pillow/blob/master/winbuild/build.py

It looks like the --add-imaging-libs=msvcrt option is added for VS2015, not sure why that would be needed though.

Also, it looks like the imaging lib from pip doesn't link against tiff and zlib like the conda-forge one does...

DancingQuanta commented 4 years ago

i have managed to get around this by installing pillow by

conda uninstall pillow --force-remove
pip install pillow==5.4.1

where I installed 5.4.1 version of pillow by pip.

mcs07 commented 4 years ago

I just tried building a custom pillow package with the following modification to bld.bat:

%PYTHON% -m pip install . --no-deps --ignore-installed --no-cache-dir -vvv --global-option="build_ext" --global-option="--disable-tiff" --global-option="--disable-zlib"

i.e. disabling tiff and zlib support - and it seems to fix this issue.

jakirkham commented 4 years ago

Does it need both tiff and zlib support disabled or is one of them particularly suspect? Also are there certain versions of tiff (like older ones) that don't have this problem? Would ask the same about zlib, but it hasn't changed in a very long time. Thanks in advance for your help 🙂

mcs07 commented 4 years ago

On further testing, just downgrading libtiff seems to be enough to fix the issue for me:

>>> conda install libtiff=4.0

The following packages will be DOWNGRADED:

  libtiff                                  4.1.0-h2e92f26_0 --> 4.0.10-h6512ee2_1003
  zstd                                     1.4.3-hd8a0e53_0 --> 1.4.0-hd8a0e53_0

So it seems the problem may be related to the libtiff 4.1.0 package that was released about 9 days ago. However, the first reports of the issue are from at least 23 days ago when the pillow 6.2.1 package was released, so that's a bit confusing...

mcs07 commented 4 years ago

This issue for zstd looks like it could be the cause:

jpgill86 commented 4 years ago

This issue for zstd looks like it could be the cause:

* [conda-forge/libtiff-feedstock#44](https://github.com/conda-forge/libtiff-feedstock/issues/44)

* [conda-forge/zstd-feedstock#36](https://github.com/conda-forge/zstd-feedstock/pull/36)

It was, in fact, because of this very DLL issue with pillow that I ended up creating the issue at conda-forge/libtiff-feedstock#44 (and I did not discover this report until just now!). The strange thing is that this doesn't affect my other PC, but I also found that downgrading libtiff was a viable workaround.

ocefpaf commented 4 years ago

The zstd rebuild fixed it. Closing this. Please re-open if you are still experiencing this issue.

bluepotatoes commented 3 years ago

Hello,

I am encountering this issue on Windows when doing a fresh Conda install of MatPlotLib.

For me, the issue can be reproduced with from PIL import Image.

from PIL import Image
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-b7f01c2f8cfe> in <module>
----> 1 from PIL import Image

~\Miniconda3\envs\017\lib\site-packages\PIL\Image.py in <module>
     92     # Also note that Image.core is not a publicly documented interface,
     93     # and should be considered private and subject to change.
---> 94     from . import _imaging as core
     95 
     96     if __version__ != getattr(core, "PILLOW_VERSION", None):

ImportError: DLL load failed while importing _imaging: The specified module could not be found.
jakirkham commented 3 years ago

@bluepotatoes could you please open a new issue and fill in the info requested in the issue template? This issue is over a year old so is likely discussing a different packaging problem than you are seeing today