Skip to content
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

Error with _fblas #11826

Closed
zoeherri opened this issue Apr 8, 2020 · 21 comments
Closed

Error with _fblas #11826

zoeherri opened this issue Apr 8, 2020 · 21 comments
Milestone

Comments

@zoeherri
Copy link

zoeherri commented Apr 8, 2020

I am trying to use scipy.spatial.distance.cdist
I can import scipy but cannot call or import scipy.spatial
I have searched the web and found other posts similar to this but none have worked for me. I tried different versions of scipy, numpy and python itself. I continue to get the error shown in the image below. I do not appear to have _fblas.py. I searched the C drive of my computer and all it returned was test_fblas.py, which is present in the test folder within the scipy folder. I appreciate any help leading to the resolution of this hours long quest.
error

@petacreepers23
Copy link

I have the same issue, couldn't find a fix either

@rgommers
Copy link
Member

Could you please add some details on how you installed Python, how you installed SciPy, and provide relevant debugging info like $ ls site-packages/scipy/linalg/ and the output of scipy.show_config()?

@petacreepers23
Copy link

i am on windows, installed python via windows 10 store.
scipy installed via pip using command shown in https://www.scipy.org/install.html

the ls you ask for:

hon37\site-packages\scipy\linalg> ls


    Directorio: C:\Users\reiva\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\linalg


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       13/04/2020     18:04                src
d-----       13/04/2020     18:04                tests
d-----       13/04/2020     18:04                __pycache__
-a----       13/04/2020     18:04          56481 basic.py
-a----       13/04/2020     18:04          10519 blas.py
-a----       13/04/2020     18:04         211456 cython_blas.cp37-win_amd64.pyd
-a----       13/04/2020     18:04          14717 cython_blas.pxd
-a----       13/04/2020     18:04         644608 cython_lapack.cp37-win_amd64.pyd
-a----       13/04/2020     18:04         195600 cython_lapack.pxd
-a----       13/04/2020     18:04          52862 decomp.py
-a----       13/04/2020     18:04          11790 decomp_cholesky.py
-a----       13/04/2020     18:04           6757 decomp_lu.py
-a----       13/04/2020     18:04          13497 decomp_qr.py
-a----       13/04/2020     18:04          10318 decomp_schur.py
-a----       13/04/2020     18:04          14706 decomp_svd.py
-a----       13/04/2020     18:04           1728 flinalg.py
-a----       13/04/2020     18:04          30964 interpolative.py
-a----       13/04/2020     18:04          12944 lapack.py
-a----       13/04/2020     18:04            159 linalg_version.py
-a----       13/04/2020     18:04          18280 matfuncs.py
-a----       13/04/2020     18:04           6453 misc.py
-a----       13/04/2020     18:04           6058 setup.py
-a----       13/04/2020     18:04          34481 special_matrices.py
-a----       13/04/2020     18:04          12102 _cython_signature_generator.py
-a----       13/04/2020     18:04          12575 _decomp_ldl.py
-a----       13/04/2020     18:04           3623 _decomp_polar.py
-a----       13/04/2020     18:04          14611 _decomp_qz.py
-a----       13/04/2020     18:04         251392 _decomp_update.cp37-win_amd64.pyd
-a----       13/04/2020     18:04          12387 _expm_frechet.py
-a----       13/04/2020     18:04         580608 _fblas.cp37-win_amd64.pyd
-a----       13/04/2020     18:04        1467392 _flapack.cp37-win_amd64.pyd
-a----       13/04/2020     18:04          51200 _flinalg.cp37-win_amd64.pyd
-a----       13/04/2020     18:04          25132 _generate_pyx.py
-a----       13/04/2020     18:04         225792 _interpolative.cp37-win_amd64.pyd
-a----       13/04/2020     18:04          45192 _interpolative_backend.py
-a----       13/04/2020     18:04          28050 _matfuncs_inv_ssq.py
-a----       13/04/2020     18:04           5874 _matfuncs_sqrtm.py
-a----       13/04/2020     18:04           2787 _procrustes.py
-a----       13/04/2020     18:04           5920 _sketches.py
-a----       13/04/2020     18:04          28279 _solvers.py
-a----       13/04/2020     18:04         192512 _solve_toeplitz.cp37-win_amd64.pyd
-a----       13/04/2020     18:04           1814 _testutils.py
-a----       13/04/2020     18:04           7406 __init__.py

the output of the config:

>>> scipy.show_config()
lapack_mkl_info:
  NOT AVAILABLE
openblas_lapack_info:
    library_dirs = ['C:\\projects\\scipy-wheels\\scipy\\build\\openblas']
    libraries = ['openblas']
    language = f77
    define_macros = [('HAVE_CBLAS', None)]
lapack_opt_info:
    library_dirs = ['C:\\projects\\scipy-wheels\\scipy\\build\\openblas']
    libraries = ['openblas']
    language = f77
    define_macros = [('HAVE_CBLAS', None)]
blas_mkl_info:
  NOT AVAILABLE
blis_info:
  NOT AVAILABLE
openblas_info:
    library_dirs = ['C:\\projects\\scipy-wheels\\scipy\\build\\openblas']
    libraries = ['openblas']
    language = f77
    define_macros = [('HAVE_CBLAS', None)]
blas_opt_info:
    library_dirs = ['C:\\projects\\scipy-wheels\\scipy\\build\\openblas']
    libraries = ['openblas']
    language = f77
    define_macros = [('HAVE_CBLAS', None)]

also, apart from
from scipy import linalg
this
from scipy import signal
also fails to load the _fblas

@rgommers
Copy link
Member

There's a file _fblas.cp37-win_amd64.pyd right there, it's unclear to me why that wouldn't be importable. Can you import it if you cd to that directory and directly do import _fblas?

installed python via windows 10 store.

unless there's a recurrence of the DLL load library path issue here ....

@zoeherri did you also install Python from the Windows Store?

@rgommers
Copy link
Member

There's a file _fblas.cp37-win_amd64.pyd right there, it's unclear to me why that wouldn't be importable. Can you import it if you cd to that directory in your Python interpreter and directly do import _fblas?

installed python via windows 10 store.

unless there's a recurrence of the DLL load library path issue here ....

@zoeherri did you also install Python from the Windows Store?

@petacreepers23
Copy link

@rgommers didn't work, same error "cannot find module"

PS C:\Users\reiva\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\linalg> python
Python 3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 11:52:54) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import _fblas
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed: No se puede encontrar el módulo especificado.

@rgommers
Copy link
Member

Yes, I think this is a duplicate of gh-10171, Windows Store Python 3.7 is problematic. Could you upgrade to 3.8?

@rgommers
Copy link
Member

Oh this brings back bad memories. @tylerjereddy the distributor_init.py is only copied into our wheels for Python 3.8: https://github.com/MacPython/scipy-wheels/blob/9da5817775eedebfa0eb929ae6a007085ad8d60b/appveyor.yml#L176

Python 3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020

This is a new micro release. I suspect the DLL path resolution was changed in that release.

@petacreepers23 could you download https://github.com/MacPython/scipy-wheels/blob/master/_distributor_init.py and put it in the main scipy directory, and see if that fixes things for you when you do from scipy import linalg (or any other module that fails right now)?

@petacreepers23
Copy link

ok @rgommers i uninstalled windows store version, and installed python 3.7.7 from python.org, I cannot use python 3.8 because of other dependencies.
removed all win_store envioroment variables, replacing them with the new python install and upgrade pip and reinstall all, and now it works with no problem, without downloading that.

It seems the problem is microsoft store python... too bad for that UWP api that might use...

tylerjereddy added a commit to tylerjereddy/scipy-wheels that referenced this issue Apr 13, 2020
* we've been getting reports of new Python 3.7
patch releases from Windows store causing SciPy DLL
load issues: scipy/scipy#11826

* so, extend the `_distributor_init.py` machinery usage
to include Python 3.7 and up for our wheels

* simplify the appveyor `matplotlib` install now that
there are stable releases available for Python `3.8`
@tylerjereddy
Copy link
Contributor

I've opened the cross-linked wheels PR above to include Python 3.7 for _distributor_init.py. For now my plan is to focus on the wheels master branch because of other things going on there, but we could consider backporting to 1.4.x if it is really important--just worried that would spread me a bit thin if we try to remove rackspace stuff from 1.4.x as well.

@rgommers
Copy link
Member

Thanks Tyler. Let's see if more reports come in and if we get confirmation that the "copy in _distributor_init.py file fixes it. Still a bit fuzzy on whether this really came in with the new Python 3.7.7 or not.

@petacreepers23
Copy link

I found some weird behaviour, not affecting my development of apps, but just as a curiosity,
i did cd to site-packages/scipy/linalg/ just like at the begining, opened python there and tried import _fblas and the error persists, but, importing linalg from the whole lib don't fail:

PS C:\Users\reiva\AppData\Local\Programs\Python\Python37\Lib\site-packages\scipy\linalg> python
Python 3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import _fblas
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed: No se puede encontrar el módulo especificado.
>>> from scipy import linalg
>>> from scipy.linalg import _fblas

Also the _distributor_init.py is in this normal version of python, but the file just have some commented lines. I'll try the win10store version and let you know.

@rgommers
Copy link
Member

Also the _distributor_init.py is in this normal version of python, but the file just have some commented lines. I'll try the win10store version and let you know.

Yeah there's a default dummy file, which needs to be replaced depending on how binaries are built.

@petacreepers23
Copy link

ok, reinstalled win10 python, and still have problems while importing linalg.
I tried replacing with

@petacreepers23 could you download https://github.com/MacPython/scipy-wheels/blob/master/_distributor_init.py and put it in the main scipy directory, and see if that fixes

and it works! , with that file i can import signal and linalg

@rgommers
Copy link
Member

Great thanks @petacreepers23. That's at least an easy workaround for others who hit this issue. We can include this fix in the next release.

@tylerjereddy
Copy link
Contributor

I have a question here since I've been struggling a bit with the fix in our wheels repo--would it be "ok" to only apply the fix to 64-bit Windows wheels with Python 3.7? I noticed in the Windows store that Python 3.7 has "x64" as minimum arch requirement, so technically users should have the option to use 64-bit mode?

https://www.microsoft.com/en-us/p/python-37/9nj46sx7x90p?activetab=pivot:regionofsystemrequirementstab

Another perhaps-reasonable excuse for this shortcut is that Python 3.7 in windows store is described as experimental, so that 32-bit DLL resolution rabbit hole might best be revisited later:

NOTE: The Microsoft Store release of Python 3.7 is primarily for evaluation purposes, and not all features are guaranteed stable. See https://docs.python.org/3.7/using/windows.html for more information, or consider searching for Python 3.8 in the store instead.

@rgommers
Copy link
Member

So is adding the _distributor_init.py breaking something?

Leaving out 32-bit for now seems okay if needed. I would make sure it's unconditionally applied for 64-bit though, otherwise we'll run into it again for 3.6 or 3.9

@zoeherri
Copy link
Author

zoeherri commented Apr 22, 2020

There's a file _fblas.cp37-win_amd64.pyd right there, it's unclear to me why that wouldn't be importable. Can you import it if you cd to that directory and directly do import _fblas?

installed python via windows 10 store.

unless there's a recurrence of the DLL load library path issue here ....

@zoeherri did you also install Python from the Windows Store?

I did not install from the windows store. I used https://www.python.org/downloads/ to get the latest version and to pull 3.7 in case it was a but with the latest. I used pip to uninstall and reinstall scipy but when reinstalling it calls from a cache. I am currently uninstalling python and all related libraries to start from scratch.
I have another computer which had never had python on it before so I installed the latest version from the site above, used pip to install numpy and scipy then tried and had no errors. I initially had jupyter notebook and anaconda on the machine having problems so I wonder if this is causing an issue

@zoeherri
Copy link
Author

I ended up clearing the cache, reinstalling and then telling it to update scipy once installed. I can now import scipy and associated libraries.

@tylerjereddy
Copy link
Contributor

I think I'm reasonably happy with the current version of the proposed fix in: MacPython/scipy-wheels#70

It adds a _distributor_init.py to all versions of Python wheel we support for Windows (32 and 64-bit/Python 3.6, 3.7, 3.8) in next release.

The main trick was to add a os.chdir() call to move right into the DLL path, which seems to help with DLL resolution for older Python versions; it should have no effect for Python 3.8+. It moves back to the original dir after.

The only remaining failures in that PR are unrelated: #11095

rgommers pushed a commit to MacPython/scipy-wheels that referenced this issue Apr 30, 2020
* MAINT: init file and mpl updates

* we've been getting reports of new Python 3.7
patch releases from Windows store causing SciPy DLL
load issues: scipy/scipy#11826

* so, extend the `_distributor_init.py` machinery usage
to include Python 3.7 and up for our wheels

* simplify the appveyor `matplotlib` install now that
there are stable releases available for Python `3.8`

* MAINT: update .travis.yml

* fix warnings in `.travis.yml` based on feedback from
https://config.travis-ci.com/explore

* bump distro to `bionic` since NumPy did this recently too

* attempting to restore Travis CI runs to our wheels
build matrix

* MAINT: revise PR 70

* try using `[System.Version]` for more robust
Python version comparisons in powershell

* MAINT: PR 70 revisions

* update minimum NumPy version to `1.14.5`

* the distutils override for appveyor/Windows
builds now only happens for Python < 3.7, since
we have now added the `_distributor_init.py`
for Python 3.7 (not just Python 3.8)

* DEBUG: try newer NumPy

* try using newer NumPy version for Windows Python 3.7
builds, to see if this helps `check_installed_package.py`

* Add debug prints to _distributor_init.py

* Debug print contents of .libs path for DLLs

* Make sure libs_path exists before trying to debug print contents.

* DEBUG: simplify CI matrix for iteration.

* DEBUG: more debug prints near point of 32-bit Python 3.7 DLL resolution failure.

* DEBUG: try moving into DLL dir

* try to solve DLL resolution issues for older
(32-bit) Python versions by temporarily moving into the
path where they are stored prior to load attempts
in `_distributor_init.py`

* Revert "DEBUG: simplify CI matrix for iteration."

This reverts commit 46e69e1.

* MAINT: PR 70 cleanup

* remove some debug prints

* revert some debug changes

* use `_distributor_init.py` with Python 3.6+
(all supported Python versions)

* MAINT: PR 70 revisions

* wrap the `_distributor_init.py` `os.chdir` code in a
`try .. finally` block to ensure restoration of the working
directory if something fails

* substantially expand the comments describing the rationale
for the working directory changes in `_distributor_init.py`

* MAINT: PR 70 revisions

* sync multibuild submodule to latest `devel` branch
checkout in attempt to deal with Travis CI failures
that just started appearing
@tylerjereddy tylerjereddy added this to the 1.5.0 milestone May 6, 2020
@rgommers
Copy link
Member

rgommers commented May 8, 2020

The fix was merged, so let's close this. The 1.5.0 wheels will have the fix, if anyone runs into this with 1.4.1 please use this workaround: #11826 (comment) (a 1.4.2 may follow, but not guaranteed).

Thanks everyone!

@rgommers rgommers closed this as completed May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants