question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot import torchaudio with torch 1.1

See original GitHub issue

I am trying to use torchaudio with torch 1.1. It compiled successfully with Python 3.6, but when I want to import the torchaudio package, I get this error:

>>> import torchaudio
Traceback (most recent call last):
  File "/home/daniel/envs/pytorch-py3/lib/python3.6/site-packages/torch/jit/annotations.py", line 95, in parse_type_line
    arg_ann = eval(arg_ann_str, _eval_env)
  File "<string>", line 1, in <module>
NameError: name 'Optional' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/daniel/envs/pytorch-py3/lib/python3.6/site-packages/torchaudio-0.2-py3.6-linux-x86_64.egg/torchaudio/__init__.py", line 7, in <module>
    from torchaudio import transforms, datasets, kaldi_io, sox_effects, legacy
  File "/home/daniel/envs/pytorch-py3/lib/python3.6/site-packages/torchaudio-0.2-py3.6-linux-x86_64.egg/torchaudio/transforms.py", line 6, in <module>
    from . import functional as F
  File "/home/daniel/envs/pytorch-py3/lib/python3.6/site-packages/torchaudio-0.2-py3.6-linux-x86_64.egg/torchaudio/functional.py", line 108, in <module>
    @torch.jit.script
  File "/home/daniel/envs/pytorch-py3/lib/python3.6/site-packages/torch/jit/__init__.py", line 824, in script
    fn = torch._C._jit_script_compile(ast, _rcb, get_default_args(obj))
  File "/home/daniel/envs/pytorch-py3/lib/python3.6/site-packages/torch/jit/annotations.py", line 55, in get_signature
    return parse_type_line(type_line)
  File "/home/daniel/envs/pytorch-py3/lib/python3.6/site-packages/torch/jit/annotations.py", 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

It ran fine on torch 1.0 - maybe some problem with differing source code between torch 1.0 and 1.1?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:18
  • Comments:24 (10 by maintainers)

github_iconTop GitHub Comments

12reactions
jamarshoncommented, Jun 9, 2019

Yes this is a known issue. We are currently working on a fix and will update this when resolved

11reactions
tobyclhcommented, Jun 16, 2019

same issue, working after I check out d92de5b97fc6204db4b1e3ed20c03ac06f5d53f0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot import torchaudio - audio - PyTorch Forums
I have an error when trying to import torchaudio: >>> import torchaudio ...
Read more >
Developers - Cannot import torchaudio with torch 1.1 -
Coming soon: A brand new website interface for an even better experience!
Read more >
How to resolve the hugging face error ImportError: cannot ...
SO related: Transformer: Error importing packages. "ImportError: cannot import name 'SAVE_STATE_WARNING' from 'torch.optim.lr_scheduler'"; HF ...
Read more >
pytorch lightning import error - You.com | The AI Search ...
I guess this is an outdated issue as we have cut out TorchMetrics to a standalone package. Please, check out the latest PytorchLightning....
Read more >
How to resolve the hugging face error ImportError: cannot ...
I was trying to use the ViTT transfomer. I got the following error with code: from pathlib import Path import torchvision from typing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found