Error occurred when I tried to import torchaudio

I installed torchaudio according to the instruction by Nevertheless, when I tried to import torchaudio, the following error message popped up:

Traceback (most recent call last):
File “”, line 1, in
import torchaudio
File “/Users/q7/Desktop/Wavenet/audio-master/torchaudio/”, line 7, in
from torchaudio import transforms, datasets, kaldi_io, sox_effects, legacy, compliance
File “/Users/q7/Desktop/Wavenet/audio-master/torchaudio/”, line 6, in
from . import functional as F
File “/Users/q7/Desktop/Wavenet/audio-master/torchaudio/”, line 108, in
File “/anaconda3/lib/python3.7/site-packages/torch/jit/”, line 824, in script
fn = torch._C._jit_script_compile(ast, _rcb, get_default_args(obj))
File “/anaconda3/lib/python3.7/site-packages/torch/jit/”, line 55, in get_signature
return parse_type_line(type_line)
File “/anaconda3/lib/python3.7/site-packages/torch/jit/”, line 97, in parse_type_line
raise RuntimeError(“Failed to parse the argument list of a type annotation: {}”.format(str(e)))
RuntimeError: Failed to parse the argument list of a type annotation: name ‘Optional’ is not defined

Can someone propose a solution? Thanks a lot.

I am having the same problem. Using torch 1.1.0.

1 Like

There was bad commit in torchaudio. Solution: old version with pytorch 1.0.
pip3 install git+

Any other alternative?
This fails on current version
transform = torchaudio.transforms.DownmixMono(channels_first=True)
__init__() got an unexpected keyword argument 'channels_first'

The __init__ method just contains a pass statement.

I also have the same issue.

Used Maksim_Pershin’s old version successfully for now.

Can you try this?

import sys
'3.6.8 (default, Jan 14 2019, 11:02:34) \n[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]'
!cat /usr/local/cuda/version.txt
CUDA Version 10.0.130
# Install dependencies
!apt-get install sox libsox-dev libsox-fmt-all

Go to the following link and check for links corresponding to your python and CUDA versions

!pip3 install
!pip3 install
# install torchaudio
!pip install git+
# Run torchaudio
import torchaudio
print(torchaudio.__version__)  # prints 0.2.0a0+7d7342f