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

Import error due to inflect #1322

Open
uyuutosa opened this issue Jul 2, 2023 · 0 comments
Open

Import error due to inflect #1322

uyuutosa opened this issue Jul 2, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@uyuutosa
Copy link

uyuutosa commented Jul 2, 2023

Related to Tacotron2/Pytorch

Describe the bug
When I run train.py on PyTorch/SpeechSynthesis/Tacotron2/, following error occured:

Traceback (most recent call last):
  File "train.py", line 44, in <module>
    import data_functions
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/data_functions.py", line 29, in <module>
    from tacotron2.data_function import TextMelCollate
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/data_function.py", line 33, in <module>
    from tacotron2.text import text_to_sequence
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/__init__.py", line 3, in <module>
    from tacotron2.text import cleaners
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/cleaners.py", line 16, in <module>
    from .numbers import normalize_numbers
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/numbers.py", line 3, in <module>
    import inflect
  File "/opt/conda/lib/python3.8/site-packages/inflect/__init__.py", line 77, in <module>
    from pydantic.typing import Annotated
ImportError: cannot import name 'Annotated' from 'pydantic.typing' (/opt/conda/lib/python3.8/site-packages/pydantic/typing.py)
Traceback (most recent call last):
  File "train.py", line 44, in <module>
    import data_functions
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/data_functions.py", line 29, in <module>
    from tacotron2.data_function import TextMelCollate
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/data_function.py", line 33, in <module>
    from tacotron2.text import text_to_sequence
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/__init__.py", line 3, in <module>
    from tacotron2.text import cleaners
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/cleaners.py", line 16, in <module>
    from .numbers import normalize_numbers
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/numbers.py", line 3, in <module>
    import inflect
  File "/opt/conda/lib/python3.8/site-packages/inflect/__init__.py", line 77, in <module>
    from pydantic.typing import Annotated
ImportError: cannot import name 'Annotated' from 'pydantic.typing' (/opt/conda/lib/python3.8/site-packages/pydantic/typing.py)
Traceback (most recent call last):
  File "train.py", line 44, in <module>
    import data_functions
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/data_functions.py", line 29, in <module>
    from tacotron2.data_function import TextMelCollate
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/data_function.py", line 33, in <module>
    from tacotron2.text import text_to_sequence
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/__init__.py", line 3, in <module>
    from tacotron2.text import cleaners
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/cleaners.py", line 16, in <module>
    from .numbers import normalize_numbers
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/numbers.py", line 3, in <module>
    import inflect
  File "/opt/conda/lib/python3.8/site-packages/inflect/__init__.py", line 77, in <module>
    from pydantic.typing import Annotated
ImportError: cannot import name 'Annotated' from 'pydantic.typing' (/opt/conda/lib/python3.8/site-packages/pydantic/typing.py)
Traceback (most recent call last):
  File "train.py", line 44, in <module>
    import data_functions
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/data_functions.py", line 29, in <module>
    from tacotron2.data_function import TextMelCollate
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/data_function.py", line 33, in <module>
    from tacotron2.text import text_to_sequence
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/__init__.py", line 3, in <module>
    from tacotron2.text import cleaners
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/cleaners.py", line 16, in <module>
    from .numbers import normalize_numbers
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/numbers.py", line 3, in <module>
    import inflect
  File "/opt/conda/lib/python3.8/site-packages/inflect/__init__.py", line 77, in <module>
    from pydantic.typing import Annotated
ImportError: cannot import name 'Annotated' from 'pydantic.typing' (/opt/conda/lib/python3.8/site-packages/pydantic/typing.py)
Traceback (most recent call last):
  File "train.py", line 44, in <module>
    import data_functions
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/data_functions.py", line 29, in <module>
    from tacotron2.data_function import TextMelCollate
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/data_function.py", line 33, in <module>
    from tacotron2.text import text_to_sequence
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/__init__.py", line 3, in <module>
    from tacotron2.text import cleaners
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/cleaners.py", line 16, in <module>
    from .numbers import normalize_numbers
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/numbers.py", line 3, in <module>
    import inflect
  File "/opt/conda/lib/python3.8/site-packages/inflect/__init__.py", line 77, in <module>
    from pydantic.typing import Annotated
ImportError: cannot import name 'Annotated' from 'pydantic.typing' (/opt/conda/lib/python3.8/site-packages/pydantic/typing.py)
Traceback (most recent call last):
  File "train.py", line 44, in <module>
    import data_functions
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/data_functions.py", line 29, in <module>
    from tacotron2.data_function import TextMelCollate
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/data_function.py", line 33, in <module>
    from tacotron2.text import text_to_sequence
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/__init__.py", line 3, in <module>
    from tacotron2.text import cleaners
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/cleaners.py", line 16, in <module>
    from .numbers import normalize_numbers
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/numbers.py", line 3, in <module>
    import inflect
  File "/opt/conda/lib/python3.8/site-packages/inflect/__init__.py", line 77, in <module>
    from pydantic.typing import Annotated
ImportError: cannot import name 'Annotated' from 'pydantic.typing' (/opt/conda/lib/python3.8/site-packages/pydantic/typing.py)
Traceback (most recent call last):
  File "train.py", line 44, in <module>
    import data_functions
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/data_functions.py", line 29, in <module>
    from tacotron2.data_function import TextMelCollate
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/data_function.py", line 33, in <module>
    from tacotron2.text import text_to_sequence
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/__init__.py", line 3, in <module>
    from tacotron2.text import cleaners
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/cleaners.py", line 16, in <module>
    from .numbers import normalize_numbers
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/numbers.py", line 3, in <module>
    import inflect
  File "/opt/conda/lib/python3.8/site-packages/inflect/__init__.py", line 77, in <module>
    from pydantic.typing import Annotated
ImportError: cannot import name 'Annotated' from 'pydantic.typing' (/opt/conda/lib/python3.8/site-packages/pydantic/typing.py)
Traceback (most recent call last):
  File "train.py", line 44, in <module>
    import data_functions
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/data_functions.py", line 29, in <module>
    from tacotron2.data_function import TextMelCollate
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/data_function.py", line 33, in <module>
    from tacotron2.text import text_to_sequence
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/__init__.py", line 3, in <module>
    from tacotron2.text import cleaners
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/cleaners.py", line 16, in <module>
    from .numbers import normalize_numbers
  File "/workspace/benchmark/SpeechSynthesis/Tacotron2/tacotron2/text/numbers.py", line 3, in <module>
    import inflect
  File "/opt/conda/lib/python3.8/site-packages/inflect/__init__.py", line 77, in <module>
    from pydantic.typing import Annotated
ImportError: cannot import name 'Annotated' from 'pydantic.typing' (/opt/conda/lib/python3.8/site-packages/pydantic/typing.py)

To Reproduce

When I attempted to execute the following command in conjunction with these instructions, the aforementioned error occurred.

bash scripts/train_tacotron2.sh

Expected behavior
train.py works without ImportError.

Environment

  • Container version (e.g. pytorch:19.05-py3): nvcr.io/nvidia/pytorch:20.06-py3
  • GPUs in the system: (e.g. 8x Tesla V100-SXM2-16GB): 8xA100 80GB SXM4
  • CUDA driver version (e.g. 418.67): 525.105.17

Based on my investigation, it seems that this error has emerged due to a lack of backward compatibility between Pydantic 2.0 and Inflect. The issue was highlighted in this GitHub discussion and the proposed solution was to use a specific version of pydantic (1.10.10). As a result, I was able to fix the error by adding pydantic==1.10.10 to the requirements.txt file, immediately after the inflect entry, like this:

matplotlib
numpy
inflect
pydantic==1.10.10 # added
librosa
scipy
resampy==0.3.1
git+https://github.com/NVIDIA/[email protected]#egg=dllogger

However, to manage the version dependency more effectively, I suggest using a dependency management tool like Poetry, as it can be challenging to handle this solely through requirements.txt.

@uyuutosa uyuutosa added the bug Something isn't working label Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant