conda-forge / netcdf4-feedstock

A conda-smithy repository for netcdf4.
BSD 3-Clause "New" or "Revised" License
3 stars 25 forks source link

ImportError: DLL load failed #78

Closed mullenkamp closed 5 years ago

mullenkamp commented 5 years ago

Issue:

import netCDF4

produces:

ImportError: DLL load failed: The specified module could not be found.

reproduce with:

conda create -n nctest -c conda-forge python=3.6 netcdf4

By the way, using the anaconda channel instead of conda-forge does not produce this error.


Environment (conda list):

``` # Name Version Build Channel bzip2 1.0.6 hfa6e2cd_1002 conda-forge ca-certificates 2019.3.9 hecc5488_0 conda-forge certifi 2019.3.9 py36_0 conda-forge cftime 1.0.3.4 py36h452e1ab_1000 conda-forge curl 7.64.0 h4496350_2 conda-forge hdf4 4.2.13 hf8e6fe8_1002 conda-forge hdf5 1.10.4 nompi_hcc15c50_1105 conda-forge intel-openmp 2019.1 144 jpeg 9c hfa6e2cd_1001 conda-forge krb5 1.16.3 hdd46e55_1001 conda-forge libblas 3.8.0 4_mkl conda-forge libcblas 3.8.0 4_mkl conda-forge libcurl 7.64.0 h4496350_2 conda-forge liblapack 3.8.0 4_mkl conda-forge libnetcdf 4.6.2 h396784b_1001 conda-forge libssh2 1.8.1 h642c060_0 conda-forge mkl 2019.1 144 netcdf4 1.4.3.2 py36h2b7c3b1_0 conda-forge numpy 1.16.2 py36h8078771_1 conda-forge openssl 1.1.1b hfa6e2cd_2 conda-forge pip 19.0.3 py36_0 conda-forge python 3.6.7 he025d50_1004 conda-forge setuptools 40.8.0 py36_0 conda-forge tk 8.6.9 hfa6e2cd_1000 conda-forge vc 14 0 conda-forge vs2015_runtime 14.0.25420 0 conda-forge wheel 0.33.1 py36_0 conda-forge wincertstore 0.2 py36_1002 conda-forge zlib 1.2.11 h2fa13f4_1004 conda-forge ```


Details about conda and system ( conda info ):

``` active environment : nctest active env location : E:\programs\anaconda3_64bit\envs\nctest shell level : 1 user config file : C:\Users\michaelek\.condarc populated config files : C:\Users\michaelek\.condarc conda version : 4.6.8 conda-build version : 3.17.8 python version : 3.6.7.final.0 base environment : E:\programs\anaconda3_64bit (writable) channel URLs : https://conda.anaconda.org/conda-forge/win-64 https://conda.anaconda.org/conda-forge/noarch https://conda.anaconda.org/mullenkamp/win-64 https://conda.anaconda.org/mullenkamp/noarch https://conda.anaconda.org/anaconda-fusion/win-64 https://conda.anaconda.org/anaconda-fusion/noarch https://repo.anaconda.com/pkgs/main/win-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/free/win-64 https://repo.anaconda.com/pkgs/free/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 : E:\programs\anaconda3_64bit\pkgs C:\Users\michaelek\.conda\pkgs C:\Users\michaelek\AppData\Local\conda\conda\pkgs envs directories : E:\programs\anaconda3_64bit\envs C:\Users\michaelek\.conda\envs C:\Users\michaelek\AppData\Local\conda\conda\envs platform : win-64 user-agent : conda/4.6.8 requests/2.21.0 CPython/3.6.7 Windows/10 Windows/10.0.14393 administrator : False netrc file : None offline mode : False ```
ocefpaf commented 5 years ago

@isuruf I test a few of the latest version and they are all broken like that. Could this be related to the blas change?

mullenkamp commented 5 years ago

Thanks for being so prompt. I tested it out again after doing a conda clean --all just to make sure I would download the newest version, but it still failed unfortunately. I think I'll also open an issue related to updating the .appveyor.yml to run the run_test.py as part of the CI process to catch these kind of things early on.

ocefpaf commented 5 years ago

@conda-forge/core and Windows experts (@gillins, @patricksnape, @mingwandroid and @isuruf) do you have an idea of what may be going on here? Everything works just fine in AppVeyor but crashes on a real machine. I test and, even with exact the same packages as the AppVeyor build, the DLL error persists :-(

gillins commented 5 years ago

Hmm - seems fine for me. If you have a machine that has this error, my suggestion is to use http://www.dependencywalker.com/ to find out which library is missing. Activate your environment first and run depends.exe, then load up the _netcdf4.cp36-win_amd64.pyd file and see if you can find what is missing... Might be a lib that is only installed with MSVC or something weird like that (AppVeyor would have all that installed).

ocefpaf commented 5 years ago

Thanks for the Windows tips @gillins! It looks like that, on my machine, I'm missing libeay32.dll. @isuruf also raised the possibility of AppVeyor being the culprit in that "contamination." Not sure how to proceed to fix that... @mariusvniekerk raised the option of restricting the PATH during the build.

For now I'm going to see if I can build it locally on my machine and do a manual upload just to get this "fixed." But we need a long term solution for it.

xylar commented 5 years ago

@ocefpaf, I'm no Windows expert but this sounds more to me like a problem with the Windows build of openssl not including libeay32.dll in its installation rather than anything specific to the NetCDF4 build. Are you hoping that a local build just won't depend on that DLL?

ocefpaf commented 5 years ago

Are you hoping that a local build just won't depend on that DLL?

Nope. I'm hoping it will fail with a more informative error 😬

I'm rebuilding things as are as I can to see if I can fix this. (It will take a while, my Windows machine is old and tired 😩)

ocefpaf commented 5 years ago

I had to rebuild curl to get it right. Let's hope that will work on AppVeyor too.

ocefpaf commented 5 years ago

It did not work :-/ We are still getting:

(TEST) C:\Users\filipe>python
Python 3.7.2 | packaged by conda-forge | (default, Mar 20 2019, 01:38:26) [MSC v.1900 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import netCDF4
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Miniconda3\envs\TEST\lib\site-packages\netCDF4\__init__.py", line 3, in <module>
    from ._netCDF4 import *
ImportError: DLL load failed: The operating system cannot run %1.
>>>

Locally I rebuilt curl and netcdf4 with strict* so it is either that or something in AppVeyor.

* The amount of mixed packages on Windows is huge and I'm not 100% convinced that we are doing the right thing for openssl there.

gillins commented 5 years ago

the Windows build of openssl not including libeay32.dll

@xylar I think you are right, we need to work out why openssl isn't installing this file....

ocefpaf commented 5 years ago

This is commented out in the new recipe :-/

rem copy out32dll\libeay32.dll %LIBRARY_BIN%\libeay32.dll

ocefpaf commented 5 years ago

@gillins that was removed when we synced with AR, see https://github.com/AnacondaRecipes/openssl-feedstock/blob/master/recipe/bld.bat

I'm not sure if we really need to restore that or just rebuild things properly that they don't look for it.

gillins commented 5 years ago

Hmm saw that - but they are using nmake install. Perhaps this doesn't do what it should... If the openssl libs are linked against libeay32 we should be providing it I would have thought.

ocefpaf commented 5 years ago

Hmm saw that - but they are using nmake install. Perhaps this doesn't do what it should... If the openssl libs are linked against libeay32 we should be providing it I would have thought.

I'm not sure where the linking is happening but defaults built their stack like that and netcdf4 works. I can confirm that I rebuild libssh2, curl, and then netcdf4 and it worked too. Hopefully not picking libeay32 from my system :smile: (We know that something funky is happening on AppVeyor b/c netcdf4 does not fail there.)

mariusvniekerk commented 5 years ago

So openssl removed those dll and lib files with the 1.1 release.

https://github.com/arvidn/libtorrent/issues/1931

ocefpaf commented 5 years ago

So openssl removed those dll and lib files with the 1.1 release.

So... Are having a problem with the migration and something was not build properly or is AppVeyor contaminating our builds?

mariusvniekerk commented 5 years ago

Odds are your build may need patching

On Tue, Mar 26, 2019, 20:31 Filipe notifications@github.com wrote:

So openssl removed those dll and lib files with the 1.1 release.

So... Are having a problem with the migration and something was not build properly or is AppVeyor contaminating our builds?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/conda-forge/netcdf4-feedstock/issues/78#issuecomment-476910771, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEg9d1UgpPyoK45n6cHQstEv5vyGiYAks5varvygaJpZM4cA2X2 .

-- regards Marius van Niekerk

ocefpaf commented 5 years ago

Odds are your build may need patching

Sorry but I'm not following your comments @mariusvniekerk. Which build? netCDF4 or openssl? Patch for what?

gillins commented 5 years ago

@ocefpaf just to confirm: it is libssh2.dll that links against libeay32.dll on your machine? I think this is the culprit: https://github.com/libssh2/libssh2/blob/master/src/CMakeLists.txt#L79. Do we need to patch libssh2 to remove these lines?

For some reason on my machine I have a copy of libeay32.dll under miniconda\library\bin - not sure how that ended up there, but explains why it is working for me.

ocefpaf commented 5 years ago

@ocefpaf just to confirm: it is libssh2.dll that links against libeay32.dll on your machine?

Probably. I need to double check that. Also, that is probably what is happening on AppVeyor too. I wonder, for AppVeyor, if we need to patch or to remove the pre installed openssl. I don't have time to do this at the moment and I'm travelling next week. Sorry but I won't be able to check this anytime soon.

ocefpaf commented 5 years ago

BTW, just found this in the libssh2 AppVeyor logs:

Found OpenSSL: optimized;C:/OpenSSL-Win64/lib/VC/libeay32MD.lib;debug;C:/OpenSSL-Win64/lib/VC/libeay32MDd.lib (found version "1.0.2q") 

I'll try a build just removing that directory. Fingers crossed!

ocefpaf commented 5 years ago

@mullenkamp do you mind testing this again? In theory we have isolated the openssl from AppVeyor in libssh2 and the issue should be go.

mullenkamp commented 5 years ago

Works like a charm! I even did a conda clean --all to force conda to downloaded the packages again, and it imports fine. I'll try this again with some of these other conda-forge packages that have this same issue. Thanks again.

ocefpaf commented 5 years ago

Awesome! Thanks for checking and let us know if you find any problems with the packages again.