uafgeotools / mtuq

moment tensor uncertainty quantification
BSD 2-Clause "Simplified" License
67 stars 22 forks source link

ImportError on jupyter notebook #239

Closed Jinyin-Hu closed 8 months ago

Jinyin-Hu commented 10 months ago

Hello,

After updating the latest version of mtuq, I ran into this import error on my jupyter notebook (jupyter notebook --version: 6.5.4; Python 3.8.18). Interestingly, it is working well on the termial. Many thanks in advance.

from mtuq import Station, Origin, MomentTensor

ImportError Traceback (most recent call last) Cell In[2], line 1 ----> 1 from mtuq import Station, Origin, MomentTensor

File ~/opt/mtuq/mtuq/init.py:35 33 from mtuq.grid import Grid, UnstructuredGrid 34 from mtuq.grid_search import MTUQDataArray, MTUQDataFrame, open_ds ---> 35 from mtuq.misfit import PolarityMisfit, WaveformMisfit 36 from mtuq.process_data import ProcessData 38 # for backward compatibility

File ~/opt/mtuq/mtuq/misfit/init.py:2 ----> 2 from mtuq.misfit.waveform import WaveformMisfit 4 from mtuq.misfit.polarity import PolarityMisfit 6 # 7 # for backward compatibility 8 #

File ~/opt/mtuq/mtuq/misfit/waveform/init.py:5 2 import numpy as np 4 from copy import deepcopy ----> 5 from mtuq.misfit.waveform import level0, level1, level2 6 from mtuq.misfit.waveform._stats import estimate_sigma, calculate_norm_data 7 from mtuq.util import Null, iterable, warn

File ~/opt/mtuq/mtuq/misfit/waveform/level2.py:13 11 from mtuq.util.math import to_mij, to_rtp 12 from mtuq.util.signal import get_components, get_time_sampling ---> 13 from mtuq.misfit.waveform import c_ext_L2 16 def misfit(data, greens, sources, norm, time_shift_groups, 17 time_shift_min, time_shift_max, msg_handle, debug_level=0): 18 """ 19 Data misfit function (fast Python/C version) 20 21 See mtuq/misfit/waveform/__init__.py for more information 22 """

ImportError: cannot import name 'c_ext_L2' from partially initialized module 'mtuq.misfit.waveform' (most likely due to a circular import) (/Users/u7091895/opt/mtuq/mtuq/misfit/waveform/init.py)

Jinyin-Hu commented 10 months ago

just for an update, I downgraded my jupyter notebook to 6.0.0. then it works. Yeah!

rmodrak commented 10 months ago

thanks for the update, glad that it works

rmodrak commented 10 months ago

in case the problem recurs, rebuilding the C extensions by running the following script can also sometimes help? build_ext.sh