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

Unable to import mantid #28538

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

Unable to import mantid #28538

gvardany opened this issue Apr 21, 2020 · 8 comments
Labels
Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) Stale This label is automatically applied to issues that are automatically closed by the stale bot

Comments

@gvardany
Copy link
Contributor

gvardany commented Apr 21, 2020

With an installed version of MantidPlot or Workbench, it is impossible to import mantid from python.
It throws the following error:

image

@gvardany gvardany added Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) macOS Only The issues related to macOS only. labels Apr 21, 2020
@gvardany
Copy link
Contributor Author

$ python3
Python 3.7.4 (default, Jul  9 2019, 18:13:23) 
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from mantid.simpleapi import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Applications/MantidPlot.app/Contents/MacOS/mantid/__init__.py", line 106, in <module>
    from mantid import kernel as _kernel
  File "/Applications/MantidPlot.app/Contents/MacOS/mantid/kernel/__init__.py", line 38, in <module>
    import_mantid_cext('._kernel', 'mantid.kernel', globals())
  File "/Applications/MantidPlot.app/Contents/MacOS/mantid/utils.py", line 35, in import_mantid_cext
    lib = import_module(modulename, package)
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
SystemError: initialization of _kernel raised unreported exception

@gvardany gvardany added the High Priority An issue or pull request that if not addressed is severe enough to postponse a release. label Apr 22, 2020
@gvardany
Copy link
Contributor Author

gvardany commented Apr 22, 2020

From another report, it looks like this is not a mac only problem:

Traceback (most recent call last):
  File "C:\MantidNightlyInstall\bin\mantid\utils.py", line 35, in
import_mantid_cext
    lib = import_module(modulename, package)
  File
"C:\Users\giull\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py",
line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in
_find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 657, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 556, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1101, in
create_module
  File "<frozen importlib._bootstrap>", line 219, in
_call_with_frames_removed
ImportError: DLL load failed while importing _kernel: The specified
module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:\MantidNightlyInstall\bin\mantid\utils.py", line 39, in
import_mantid_cext
    lib = import_module(modulename.lstrip('.'))
  File
"C:\Users\giull\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py",
line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in
_find_and_load_unlocked
ModuleNotFoundError: No module named '_kernel'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<input>", line 4, in <module>
  File "C:\Program Files\JetBrains\PyCharm Community Edition
2020.1\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py",
line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\MantidNightlyInstall\bin\mantid\__init__.py", line 105, in
<module>
    from mantid import kernel as _kernel
  File "C:\Program Files\JetBrains\PyCharm Community Edition
2020.1\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py",
line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\MantidNightlyInstall\bin\mantid\kernel\__init__.py", line
36, in <module>
    import_mantid_cext('._kernel', 'mantid.kernel', globals())
  File "C:\MantidNightlyInstall\bin\mantid\utils.py", line 44, in
import_mantid_cext
    raise ImportError(msg)
ImportError: First import of "._kernel" failed with "DLL load failed
while importing _kernel: The specified module could not be found.".
Second import of "_kernel" failed with "No module named '_kernel'". 

@gvardany gvardany removed the macOS Only The issues related to macOS only. label Apr 22, 2020
@gvardany
Copy link
Contributor Author

Apparently, when using the python bundled with Mantid, it works.
However, this could and should be made to work also with the system python, as long as it is at compatible version.

@gvardany gvardany changed the title Unable to import simpleapi on mac Unable to import mantid Apr 23, 2020
@JensenKaplan
Copy link

Has there been any update to this issue?

@martyngigg
Copy link
Member

What would we mean by system Python on Mac/Windows? This should already work on Linux as we build against that version. For macOS/Windows it is much more uncertain what Python is going to be available so offering general support more challengning. I think our best bet is to use Conda. The nightly packages for Linux are available at: https://anaconda.org/mantid/mantid-framework/files.

@gvardany gvardany removed the High Priority An issue or pull request that if not addressed is severe enough to postponse a release. label Jan 15, 2021
@JackEAllen
Copy link
Contributor

Any update on this issue? I'm also experiencing the same problem on a Windows 7 machine when importing Mantid in IBEX using a version of Python3 not bundled with Mantid on NDXIRIS.

@stale
Copy link

stale bot commented Jan 10, 2022

This issue has been automatically marked as stale because it has not had activity in 6 months. It will be closed in 7 days if no further activity occurs.
Allowing issues to close as stale helps us filter out issues which can wait for future development time. All issues closed by stale bot act like normal issues; they can be searched for, commented on or reopened at any point.
If you'd like a closed stale issue to be considered, feel free to either re-open the issue directly or contact a developer.
To extend the lifetime of an issue please comment below, it helps us see that this is still affecting you and you want it fixed in the near-future. Extending the lifetime of an issue may cause the development team to prioritise it over other issues, which may be closed as stale instead.

@stale stale bot added the Stale This label is automatically applied to issues that are automatically closed by the stale bot label Jan 10, 2022
@stale
Copy link

stale bot commented Jan 17, 2022

This issue has been closed automatically. If this still affects you please re-open this issue with a comment or contact us so we can look into resolving it.

@stale stale bot closed this as completed Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) Stale This label is automatically applied to issues that are automatically closed by the stale bot
Projects
None yet
Development

No branches or pull requests

4 participants