"attempted relative import above top-level package"

17 views
Skip to first unread message

Daniel Batten

unread,
Nov 20, 2021, 1:40:51 PM11/20/21
to MFA Users
I've been getting this error repeatedly in attempting to run MFA. I've followed the readthedocs instructions to the letter. I've uninstalled, updated everything I can think to update, and reinstalled. Same issue.

I'm literate in this enough to get this far, but not to diagnose this issue on my own. Any help is greatly appreciate. 

Here's what I am getting. I have the same exact same output if I try to run it on my own data.

(aligner) MacBook-Pro-78:~ dbatten$ cd /Users/dbatten/opt/miniconda3/pkgs/montreal-forced-aligner-2.0.0b7-py38h50d1736_0/lib/python3.8/site-packages/montreal_forced_aligner

(aligner) MacBook-Pro-78:montreal_forced_aligner dbatten$ mfa validate /Users/dbatten/Downloads/Librispeech/19 english english

multilingual_ipa False
INFO - Parsing dictionary "english" without pronunciation probabilities without silence probabilities
INFO - Setting up corpus information...
Traceback (most recent call last):
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 1, in <module>
  File "/Users/dbatten/opt/miniconda3/pkgs/montreal-forced-aligner-2.0.0b7-py38h50d1736_0/lib/python3.8/site-packages/montreal_forced_aligner/multiprocessing/__init__.py", line 6, in <module>
  File "/Users/dbatten/opt/miniconda3/pkgs/montreal-forced-aligner-2.0.0b7-py38h50d1736_0/lib/python3.8/site-packages/montreal_forced_aligner/multiprocessing/__init__.py", line 6, in <module>
    from .alignment import calc_fmllr  # noqa
    from .alignment import calc_fmllr  # noqa
  File "/Users/dbatten/opt/miniconda3/pkgs/montreal-forced-aligner-2.0.0b7-py38h50d1736_0/lib/python3.8/site-packages/montreal_forced_aligner/multiprocessing/alignment.py", line 19, in <module>
  File "/Users/dbatten/opt/miniconda3/pkgs/montreal-forced-aligner-2.0.0b7-py38h50d1736_0/lib/python3.8/site-packages/montreal_forced_aligner/multiprocessing/alignment.py", line 19, in <module>
    from ..exceptions import AlignmentError, AlignmentExportError
    from ..exceptions import AlignmentError, AlignmentExportError
ValueError: attempted relative import beyond top-level package
ValueError: attempted relative import beyond top-level package
Traceback (most recent call last):
  File "/Users/dbatten/opt/miniconda3/envs/aligner/bin/mfa", line 11, in <module>
    sys.exit(main())
  File "/Users/dbatten/opt/miniconda3/envs/aligner/lib/python3.8/site-packages/montreal_forced_aligner/command_line/mfa.py", line 803, in main
    run_validate_corpus(args, unknown)
  File "/Users/dbatten/opt/miniconda3/envs/aligner/lib/python3.8/site-packages/montreal_forced_aligner/command_line/validate.py", line 148, in run_validate_corpus
    validate_corpus(args, unknown)
  File "/Users/dbatten/opt/miniconda3/envs/aligner/lib/python3.8/site-packages/montreal_forced_aligner/command_line/validate.py", line 73, in validate_corpus
    corpus = Corpus(
  File "/Users/dbatten/opt/miniconda3/envs/aligner/lib/python3.8/site-packages/montreal_forced_aligner/corpus/base.py", line 163, in __init__
    self.load()
  File "/Users/dbatten/opt/miniconda3/envs/aligner/lib/python3.8/site-packages/montreal_forced_aligner/corpus/base.py", line 270, in load
    self._load_from_source_mp()
  File "/Users/dbatten/opt/miniconda3/envs/aligner/lib/python3.8/site-packages/montreal_forced_aligner/corpus/base.py", line 366, in _load_from_source_mp
    manager = mp.Manager()
  File "/Users/dbatten/opt/miniconda3/envs/aligner/lib/python3.8/multiprocessing/context.py", line 57, in Manager
    m.start()
  File "/Users/dbatten/opt/miniconda3/envs/aligner/lib/python3.8/multiprocessing/managers.py", line 583, in start
    self._address = reader.recv()
  File "/Users/dbatten/opt/miniconda3/envs/aligner/lib/python3.8/multiprocessing/connection.py", line 250, in recv
    buf = self._recv_bytes()
  File "/Users/dbatten/opt/miniconda3/envs/aligner/lib/python3.8/multiprocessing/connection.py", line 414, in _recv_bytes
    buf = self._recv(4)
  File "/Users/dbatten/opt/miniconda3/envs/aligner/lib/python3.8/multiprocessing/connection.py", line 383, in _recv
    raise EOFError
EOFError
/Users/dbatten/opt/miniconda3/envs/aligner/lib/python3.8/multiprocessing/resource_tracker.py:96: UserWarning: resource_tracker: process died unexpectedly, relaunching.  Some resources might leak.
  warnings.warn('resource_tracker: process died unexpectedly, '
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/dbatten/opt/miniconda3/pkgs/montreal-forced-aligner-2.0.0b7-py38h50d1736_0/lib/python3.8/site-packages/montreal_forced_aligner/multiprocessing/__init__.py", line 6, in <module>
    from .alignment import calc_fmllr  # noqa
  File "/Users/dbatten/opt/miniconda3/pkgs/montreal-forced-aligner-2.0.0b7-py38h50d1736_0/lib/python3.8/site-packages/montreal_forced_aligner/multiprocessing/alignment.py", line 19, in <module>
    from ..exceptions import AlignmentError, AlignmentExportError
ValueError: attempted relative import beyond top-level package

michael.e...@gmail.com

unread,
Nov 20, 2021, 4:10:06 PM11/20/21
to MFA Users
I think you're getting this because you're in the MFA directory.  As part of the installation, "mfa" should be available regardless of your current directory (if it's not, that's a separate issue).  If you're in that folder, it's going to get confused about the path to import from, and in this case, thinks that python files are top-level, when they're nested inside a package.  If you go back to your home directory and run the mfa commands from there, these errors shouldn't pop up.

Daniel Batten

unread,
Nov 20, 2021, 7:59:35 PM11/20/21
to MFA Users
That worked! Thank you. The way you phrased it makes perfect sense and got me to persist and correct something I was doing wrong attempting to run the commands at the home directory. It worked with both the LibriSpeech data and then with my own prepared data.
Reply all
Reply to author
Forward
0 new messages