mne.io. circular import

  • MNE version: 0.24.0
  • operating system: macOS 12.0.1

I have an issue with running mne python from a script. The issue doesn’t arise if I input the code directly statement by statement in the terminal. See the error below!

(mne) andraderenew@Renes-MacBook-Air ~ % python /Users/andraderenew/Downloads/EEG_codes/mne.py
Traceback (most recent call last):
File “/Users/andraderenew/Downloads/EEG_codes/mne.py”, line 3, in
import mne
File “/Users/andraderenew/Downloads/EEG_codes/mne.py”, line 5, in
raw = mne.io.read_raw_fif(’/Users/andraderenew/Downloads/EEG_codes/raw.fif’)
AttributeError: partially initialized module ‘mne’ has no attribute ‘io’ (most likely due to a circular import)

Hello @andraderenew and welcome to the forum!

The issue is that your script has the same name as the module you’re trying to import — both are called mne. Just rename your script to something else and it should work.

Best wishes,
Richard

oh thank you very much!!!