-
Notifications
You must be signed in to change notification settings - Fork 220
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
numpy ImportError: DLL load failed: The specified module could not be found. #10628
Comments
we believe you're seeing this because of a patch to python that we added to make library finding work better. While it helps use of our conda packages, it appears that it may be breaking things installed via pip. You can downgrade to an earlier build of python to avoid the issue: conda install python=3.6.8=h9f7ef89_0 or stick to conda-installed numpy instead of pip-installed numpy. |
That addressed the issue:
thanks! |
@msarahan could you provide more information? We are getting quite a few reports on the numpy issue tracker about this |
The latest numpy builds include this patch, which is related to stuff that you might recognize as something that the numpy team tried at some point: https://github.com/AnacondaRecipes/python-feedstock/blob/master/recipe/0020-Add-CondaEcosystemModifyDllSearchPath.patch Are these test environments being activated before running python in them? If people are running python using a fixed path without activating, then the PATH stuff won't work right. |
we removed this after discovering it broke other peoples stuff :( |
I saw your patches after I'd written mine. For sure these are not really functions that an individual package should call but are functions a distro or a language implementation may find it best or necessary to call. Your patch didn't respect PATH though which is maybe why it broke so much other stuff. I take care to present the entries in PATH to AddDllDirectory() in the right order. I believe this patch (once reviewed and improved further) would ideally be accepted upstream by cpython (or that MS would just add RPATH and ORIGIN to their loader already). I need to look into a few reported issues but my hope is that this patch will work out in the end. We nearly pulled the packages tonight but held our nerve and found a bug in the CI setup of the other project that this change merely unmasked. Pulling them could still happen but so far I think these patches have worked better than I expected if I'm being honest. DLL-hell is IMHO getting worse. When DLLs with generic names from modern projects like LibreSSL turned up in C:\Windows\System32 recently from an attempt to configure a new installation for development it was the last straw. We need to do something about DLL-hell. |
Playing around I came up with this. Edit
to:
so we are calling |
The code lives in 'numpy/distutils/misc_utils.py' for obscure historical reasons. Could you submit a PR to numpy with your proposed changes? |
.. and I think having code to detect whether this is needed or not would be most beneficial, since the last time we tried this it broke other packages so we removed it. Maybe you have insights that will make the idea more robust |
Sure, we should be using
The difference between your old approach and what we're looking at is that you change Windows search order from:
to:
.. so it's not really a surprise that this breaks other things. With my patch, our Python now uses the following order:
.. which is why you can not rely on PATH itself anymore. I'll work on a PR as soon as I can. |
If you stick with using |
Maybe it would be better to use a resource file as suggested near the end of https://bugs.python.org/issue35688 |
I agree we probably should intercept this. At what level would you recommend we do that? A high level monkey-patch to the python code or something lower level? In our latest iteration we resync from
It might well be better @mattip. A manifest with relative paths would solve a lot of this and would be more clean than what I've done so far, so long as it avoids searching early in I seem to have things 'working' now for the failures I've encountered so far, albeit in a messy patch with a lot of tweakables. I'll reply when I've uploaded some packages. Thanks for the discussion so far. Bringing this to the attention of @katietz and @msarahan. |
Just to confirm the discussion and issue here, yes, it did break existing code on win platform. |
My latest version resyncs |
This all seems a bit magical. I assume this the final version?
|
I hope this far-reaching change is being discussed in a wider forum than just the commenters on this issue. |
No it isn't the final version (code's never finished). The latest can be seen at https://github.com/AnacondaRecipes/python-feedstock/blob/master/recipe/0020-Add-CondaEcosystemModifyDllSearchPath.patch We might end up using a manifest with relative paths in it for some of this patch, We attempt here to mirror as much as we can the normal DLL lookup procedure, just without
You need to set an env var at present.
Agreed we'll document it.
We have to make a judgement call about which is worse, DLL-hell or trouble for 3rd party loaders (which we'll attempt to erradicate when found). |
Thanks. I am curious, is there currently a "python interpreter differences between cpython and anaconda python" documentation page? I didn't know Anaconda patches stock python, and a quick google search was not productive. |
For sure we patch stock python (as software distros must do for many packages), you are welcome to look at the patches. I linked you to one, the others are in the same place. |
@msarahan what is the equivalent py37 version to use to avoid this problem?
That's always a healthy idea. A big part of the problem here will be caused by NumPy in defaults being out of date, which causes It's been 5 weeks since 1.16.0 came out, and 3 weeks since 1.16.1. What is the problem exactly (did we make your life more difficult in 1.16.x somehow?), and do you have an ETA? |
FYI, I just filed https://bugs.python.org/issue36085 to potentially make the painful breaking change in CPython 3.8 so that we can manage the porting process at the right version boundary. Any and all input welcome! |
Aw man, you mean I predicted the problems and the solution and you didn't want to mention me to let me know ;) Assuming you're getting away with the SetDefaultDllDirectories call (which is one of the problems numpy hit), then presumably you can update the conda builds to put all the DLLs in one directory and just AddDllDirectory that one? My concern was that you were adding a whole lot of paths from PATH that weren't relevant, so provided you can make it focused on the paths that matter, you should be okay. |
The patch is now working well but we've chickened out (for now). We had to taker care around cwd and some other details. To enable the new dll search you set CONDA_DLL_SEARCH_MODIFICATION_ENABLE env var. The only problem I've seen with the latest version is that broken dlls that were not found before now do get found. PyTorch suffered this but have removed the broken dlls. We cannot move dlls..
edit: NOTIFICATION=>MODIFICATION |
Until MS implements an alternative dll loading scheme that fixes dll hell once and for all (and I believe it's not that difficult there are two working models from which to copy!) we must reserve the option to enable this by default. Though we will probably try something with relative paths in manifests too. |
Just to be clear: What would Anaconda suggest numpy tell users who |
I'd say |
I'd also say they can set CONDA_DLL_SEARCH_MODIFICATION_ENABLE (which enables this new stuff) and that should also work fine since we fixed the bug you refer to already. |
@mingwandroid FYI, the environment variable is misspelled with |
Also see the SSL issue immediately before that topic. |
Only Python builds beyond these builds will react to these environment variables:
We should add something like "please note these fixes are not available in python 3.8 yet." |
Thanks @msarahan and @mingwandroid . I couldn't find it on Google with various queries; I had to manually go to one of the original issues we were involved in. I'd suggest broadening the title/description in the docs to include |
PR would be great! |
Okay, sure thing. I'll put it on my todo list. Did you mean to reopen this issue in light of that or was that an accident? Thanks. |
I was 50:50 on that. I should maybe change the title to say "Misspelling in docs .."? |
The misspelling isn't in the docs (which I originally was unable to find when looking up the name of the env var for the user I was helping on spyder-ide/spyder-kernels#89 , thus my question) but rather in this comment above, which in turn was linked elsewhere. I just wanted to make sure others referencing it don't make the same mistake. Then @msarahan linked me to the actual docs and I had some suggestions I offered to help with there for making them more broadly applicable to the class of problems this can fix. |
Corrected the comment, please go ahead if you have time. |
Thanks @mingwandroid - CONDA_DLL_SEARCH_MODIFICATION_ENABLE did the trick - I'd given up on using Anaconda Python outside of Jupyter and PyCharm on Windows because of this Numpy issue. I did notice despite enabling that environment variable if I use VSCode's relatively new "Run Python" button - for launching when you haven't created a launch.json I still get this problem despite enabling the environment variable - If I click Debug Python - or use the context menu to "Run Python file in Terminal I don't have any issues importing Numpy. Likewise if I create a launch.json file with default settings that runs fine too. Does anyone else get that? Should I raise a ticket with the VS Code team? |
Is it possible to install
numpy
using pip/setup.py from within a conda environment?Actual Behavior
Expected Behavior
Trying to install numpy into an anaconda environment (or use a package's
python setup.py
which has a numpy requirement)Steps to Reproduce
This used to work on my machine (and I can still load its environment to test it and it's using numpy 1.16.1), but something seems to have changed and now I can't reproduce that (working) environment. I don't remember how I created that environment, but I don't think I did anything beyond
python setup.py develop
or similar.I'm not very experienced with development on Windows, so I don't know much about how to debug dll issues.
I uninstalled anaconda this morning, and then reinstalled using chocolatey, but that didn't resolve the issue.
I get the same problem if I do this (i.e., without the
python=3.6
):and it also fails if I use
python=3.7
.I also tried uninstalling numpy from the
base
environment but that didn't work.although this does work:
I also tried this:
and that worked too (although it gave me numpy 1.15.4 instead of 1.16.1, not that I care about which version).
Anaconda or Miniconda version:
4.5.12
This is what's provided by default from chocolatey right now. Last night I tried upgrading to the most recent anaconda and it had the same issue.
Operating System:
see below
conda info
conda list --show-channel-urls
The text was updated successfully, but these errors were encountered: