jkrogager / VoigtFit

Python code to fit absorption lines semi-interactively
http://voigtfit.readthedocs.io/
MIT License
28 stars 12 forks source link

bad magic number in Voigtfit? #34

Closed keheintz closed 3 years ago

keheintz commented 3 years ago

Hi JK,

I tried pulling the latest version of VoigtFit from GitHub and ran one of my usual scripts (now using Python 3.8). However, I get the following error, any idea what it could be? Traceback (most recent call last): File "/opt/anaconda3/bin/VoigtFit", line 33, in sys.exit(load_entry_point('VoigtFit==3.11.6', 'console_scripts', 'VoigtFit')()) File "/opt/anaconda3/bin/VoigtFit", line 25, in importlib_load_entry_point return next(matches).load() File "/opt/anaconda3/lib/python3.8/importlib/metadata.py", line 77, in load module = import_module(match.group('module')) File "/opt/anaconda3/lib/python3.8/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 961, in _find_and_load_unlocked File "", line 219, in _call_with_frames_removed File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked File "", line 779, in exec_module File "", line 1064, in get_code File "", line 513, in _classify_pyc ImportError: bad magic number in 'VoigtFit': b'\x03\xf3\r\n'

jkrogager commented 3 years ago

Sounds like there might be an issue with old .pyc files from the previous version that interfere. See for instance: https://github.com/Miserlou/Zappa/issues/854

Try removing all the old files (did you install it via pip as well or only from source?) and then re-clone.

keheintz commented 3 years ago

Alright, removed all the old files + uninstalled the pip version and then re-copied the source files from here + did python setup.py install. Now I get a new error however: Traceback (most recent call last): File "/opt/anaconda3/bin/VoigtFit", line 33, in sys.exit(load_entry_point('VoigtFit==3.11.6', 'console_scripts', 'VoigtFit')()) File "/opt/anaconda3/bin/VoigtFit", line 25, in importlib_load_entry_point return next(matches).load() File "/opt/anaconda3/lib/python3.8/importlib/metadata.py", line 77, in load module = import_module(match.group('module')) File "/opt/anaconda3/lib/python3.8/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 961, in _find_and_load_unlocked File "", line 219, in _call_with_frames_removed File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked File "", line 783, in exec_module File "", line 219, in _call_with_frames_removed File "/opt/anaconda3/lib/python3.8/site-packages/VoigtFit-3.11.6-py3.8.egg/VoigtFit/init.py", line 22, in from . import dataset File "/opt/anaconda3/lib/python3.8/site-packages/VoigtFit-3.11.6-py3.8.egg/VoigtFit/dataset.py", line 18, in from . import output File "/opt/anaconda3/lib/python3.8/site-packages/VoigtFit-3.11.6-py3.8.egg/VoigtFit/output.py", line 19, in from .voigt import evaluate_profile File "/opt/anaconda3/lib/python3.8/site-packages/VoigtFit-3.11.6-py3.8.egg/VoigtFit/voigt.py", line 12, in from numba import jit File "/opt/anaconda3/lib/python3.8/site-packages/numba/init.py", line 196, in import numba.typed File "/opt/anaconda3/lib/python3.8/site-packages/numba/typed/init.py", line 3, in from .typeddict import Dict File "/opt/anaconda3/lib/python3.8/site-packages/numba/typed/typeddict.py", line 20, in def _make_dict(keyty, valty): File "/opt/anaconda3/lib/python3.8/site-packages/numba/decorators.py", line 238, in njit return jit(*args, *kws) File "/opt/anaconda3/lib/python3.8/site-packages/numba/decorators.py", line 175, in jit return wrapper(pyfunc) File "/opt/anaconda3/lib/python3.8/site-packages/numba/decorators.py", line 189, in wrapper disp = dispatcher(py_func=func, locals=locals, File "/opt/anaconda3/lib/python3.8/site-packages/numba/dispatcher.py", line 650, in init self.targetctx = self.targetdescr.target_context File "/opt/anaconda3/lib/python3.8/site-packages/numba/targets/registry.py", line 50, in target_context return self._toplevel_target_context File "/opt/anaconda3/lib/python3.8/site-packages/numba/utils.py", line 390, in get res = instance.dict[self.name] = self.func(instance) File "/opt/anaconda3/lib/python3.8/site-packages/numba/targets/registry.py", line 34, in _toplevel_target_context return cpu.CPUContext(self.typing_context) File "/opt/anaconda3/lib/python3.8/site-packages/numba/targets/base.py", line 260, in init self.init() File "/opt/anaconda3/lib/python3.8/site-packages/numba/compiler_lock.py", line 32, in _acquire_compile_lock return func(args, kwargs) File "/opt/anaconda3/lib/python3.8/site-packages/numba/targets/cpu.py", line 51, in init self._internal_codegen = codegen.JITCPUCodegen("numba.exec") File "/opt/anaconda3/lib/python3.8/site-packages/numba/targets/codegen.py", line 628, in init self._init(self._llvm_module) File "/opt/anaconda3/lib/python3.8/site-packages/numba/targets/codegen.py", line 637, in _init tm = target.create_target_machine(tm_options) TypeError: create_target_machine() got an unexpected keyword argument 'jitdebug'

jkrogager commented 3 years ago

Ahhh right... What version of numba do you have? You might have to downgrade to numba-v0.47.0 I thought I had included that in the distribution. Sorry, I'll check again.

keheintz commented 3 years ago

Hmm yes so I think that actually worked out fine, i.e. I believe VoigtFit installed Numba 0.47.0. However, I think that might be the error -- when I try to import numba in a separate python script I get the exact same error message, i.e.:

import numba Traceback (most recent call last): File "", line 1, in File "/opt/anaconda3/lib/python3.8/site-packages/numba/init.py", line 196, in import numba.typed File "/opt/anaconda3/lib/python3.8/site-packages/numba/typed/init.py", line 3, in from .typeddict import Dict File "/opt/anaconda3/lib/python3.8/site-packages/numba/typed/typeddict.py", line 20, in def _make_dict(keyty, valty): File "/opt/anaconda3/lib/python3.8/site-packages/numba/decorators.py", line 238, in njit return jit(*args, *kws) File "/opt/anaconda3/lib/python3.8/site-packages/numba/decorators.py", line 175, in jit return wrapper(pyfunc) File "/opt/anaconda3/lib/python3.8/site-packages/numba/decorators.py", line 189, in wrapper disp = dispatcher(py_func=func, locals=locals, File "/opt/anaconda3/lib/python3.8/site-packages/numba/dispatcher.py", line 650, in init self.targetctx = self.targetdescr.target_context File "/opt/anaconda3/lib/python3.8/site-packages/numba/targets/registry.py", line 50, in target_context return self._toplevel_target_context File "/opt/anaconda3/lib/python3.8/site-packages/numba/utils.py", line 390, in get res = instance.dict[self.name] = self.func(instance) File "/opt/anaconda3/lib/python3.8/site-packages/numba/targets/registry.py", line 34, in _toplevel_target_context return cpu.CPUContext(self.typing_context) File "/opt/anaconda3/lib/python3.8/site-packages/numba/targets/base.py", line 260, in init self.init() File "/opt/anaconda3/lib/python3.8/site-packages/numba/compiler_lock.py", line 32, in _acquire_compile_lock return func(args, kwargs) File "/opt/anaconda3/lib/python3.8/site-packages/numba/targets/cpu.py", line 51, in init self._internal_codegen = codegen.JITCPUCodegen("numba.exec") File "/opt/anaconda3/lib/python3.8/site-packages/numba/targets/codegen.py", line 628, in init self._init(self._llvm_module) File "/opt/anaconda3/lib/python3.8/site-packages/numba/targets/codegen.py", line 637, in _init tm = target.create_target_machine(tm_options) TypeError: create_target_machine() got an unexpected keyword argument 'jitdebug'

Is there a way to fix this and/or is it possible to use an updated version of numba? For reference I'm using Python 3.8.3.

jkrogager commented 3 years ago

Try running "pip3 search numba". That should show you what version you currently use. The latest version of numba is 0.51.2... What version are you on? If you need to downgrade try: "pip3 install numba=0.47" You can also use "conda" instead of "pip3"... Should give the same result

jkrogager commented 3 years ago

The issue has been resolved. It was related to old .pyc files and a problem in your numba package. I've tested VoigtFit on the latest version of numba (0.51.2) and it is working again, so I've changed the requirement on numba in the distribution. This (with a few updates) is released in version 3.11.6.1.