|
22 | 22 | from .importmultiarray
|
23 | 23 | exceptImportErrorasexc:
|
24 | 24 | importsys
|
25 |
| -msg=""" |
| 25 | + |
| 26 | +# Basically always, the problem should be that the C module is wrong/missing... |
| 27 | +if ( |
| 28 | +isinstance(exc,ModuleNotFoundError) |
| 29 | +andexc.name=="numpy._core._multiarray_umath" |
| 30 | + ): |
| 31 | +importsys |
| 32 | +candidates= [] |
| 33 | +forpathin__path__: |
| 34 | +candidates.extend( |
| 35 | +fforfinos.listdir(path)iff.startswith("_multiarray_umath")) |
| 36 | +iflen(candidates)==0: |
| 37 | +bad_c_module_info= ( |
| 38 | +"We found no compiled module, did NumPy build successfully?\n") |
| 39 | +else: |
| 40 | +candidate_str='\n * '.join(candidates) |
| 41 | +# cache_tag is documented to be possibly None, so just use name if it is |
| 42 | +# this guesses at cache_tag being the same as the extension module scheme |
| 43 | +tag=sys.implementation.cache_tagorsys.implementation.name |
| 44 | +bad_c_module_info= ( |
| 45 | +f"The following compiled module files exist, but seem incompatible\n" |
| 46 | +f"with with either python '{tag}' or the " |
| 47 | +f"platform '{sys.platform}':\n\n *{candidate_str}\n" |
| 48 | + ) |
| 49 | +else: |
| 50 | +bad_c_module_info="" |
| 51 | + |
| 52 | +major,minor,*_=sys.version_info |
| 53 | +msg=f""" |
26 | 54 |
|
27 | 55 | IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
|
28 | 56 |
|
29 | 57 | Importing the numpy C-extensions failed. This error can happen for
|
30 | 58 | many reasons, often due to issues with your setup or how NumPy was
|
31 | 59 | installed.
|
32 |
| -
|
| 60 | +{bad_c_module_info} |
33 | 61 | We have compiled some common reasons and troubleshooting tips at:
|
34 | 62 |
|
35 | 63 | https://numpy.org/devdocs/user/troubleshooting-importerror.html
|
36 | 64 |
|
37 | 65 | Please note and check the following:
|
38 | 66 |
|
39 |
| - * The Python version is: Python%d.%d from "%s" |
40 |
| - * The NumPy version is: "%s" |
| 67 | + * The Python version is: Python{major}.{minor} from "{sys.executable}" |
| 68 | + * The NumPy version is: "{__version__}" |
41 | 69 |
|
42 | 70 | and make sure that they are the versions you expect.
|
43 |
| -Please carefully study the documentation linked above for further help. |
44 | 71 |
|
45 |
| -Original error was: %s |
46 |
| -"""% (sys.version_info[0],sys.version_info[1],sys.executable, |
47 |
| -__version__,exc) |
| 72 | +Please carefully study the information and documentation linked above. |
| 73 | +This is unlikely to be a NumPy issue but will be caused by a bad install |
| 74 | +or environment on your machine. |
| 75 | +
|
| 76 | +Original error was:{exc} |
| 77 | +""" |
| 78 | + |
48 | 79 | raiseImportError(msg)fromexc
|
49 | 80 | finally:
|
50 | 81 | forenvkeyinenv_added:
|
|