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.

Exception at 'import torchaudio'

See original GitHub issue

Hi, I am trying to use torchaudio on Ubuntu and get the following exception:

>>> import torchaudio
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "torchaudio/__init__.py", line 5, in <module>
    from ._ext import th_sox
  File "torchaudio/_ext/th_sox/__init__.py", line 3, in <module>
    from ._th_sox import lib as _lib, ffi as _ffi
ImportError: No module named _th_soxq

All dependencies are met and up-to-date:

libsox-dev is already the newest version.
libsox-fmt-all is already the newest version.
sox is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 196 not upgraded.

Also, install process seems ok, no errors or warnings:

running install
running bdist_egg
running egg_info
writing requirements to torchaudio.egg-info/requires.txt
writing torchaudio.egg-info/PKG-INFO
writing top-level names to torchaudio.egg-info/top_level.txt
writing dependency_links to torchaudio.egg-info/dependency_links.txt
reading manifest file 'torchaudio.egg-info/SOURCES.txt'
writing manifest file 'torchaudio.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
copying torchaudio/_ext/th_sox/__init__.py -> build/lib.linux-x86_64-2.7/torchaudio/_ext/th_sox
running build_ext
generating cffi module 'build/temp.linux-x86_64-2.7/torchaudio._ext._th_sox.c'
already up-to-date
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/torchaudio
creating build/bdist.linux-x86_64/egg/torchaudio/_ext
creating build/bdist.linux-x86_64/egg/torchaudio/_ext/th_sox
copying build/lib.linux-x86_64-2.7/torchaudio/_ext/th_sox/__init__.py -> build/bdist.linux-x86_64/egg/torchaudio/_ext/th_sox
copying build/lib.linux-x86_64-2.7/torchaudio/_ext/_th_sox.so -> build/bdist.linux-x86_64/egg/torchaudio/_ext
copying build/lib.linux-x86_64-2.7/torchaudio/_ext/__init__.py -> build/bdist.linux-x86_64/egg/torchaudio/_ext
copying build/lib.linux-x86_64-2.7/torchaudio/__init__.py -> build/bdist.linux-x86_64/egg/torchaudio
byte-compiling build/bdist.linux-x86_64/egg/torchaudio/_ext/th_sox/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/torchaudio/_ext/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/torchaudio/__init__.py to __init__.pyc
creating stub loader for torchaudio/_ext/_th_sox.so
byte-compiling build/bdist.linux-x86_64/egg/torchaudio/_ext/_th_sox.py to _th_sox.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying torchaudio.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying torchaudio.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying torchaudio.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying torchaudio.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying torchaudio.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating 'dist/torchaudio-0.1-py2.7-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing torchaudio-0.1-py2.7-linux-x86_64.egg
Removing /usr/local/lib/python2.7/dist-packages/torchaudio-0.1-py2.7-linux-x86_64.egg
Copying torchaudio-0.1-py2.7-linux-x86_64.egg to /usr/local/lib/python2.7/dist-packages
torchaudio 0.1 is already the active version in easy-install.pth

Installed /usr/local/lib/python2.7/dist-packages/torchaudio-0.1-py2.7-linux-x86_64.egg
Processing dependencies for torchaudio==0.1
Searching for cffi==1.10.0
Best match: cffi 1.10.0
Adding cffi 1.10.0 to easy-install.pth file

Using /usr/local/lib/python2.7/dist-packages
Searching for pycparser==2.17
Best match: pycparser 2.17
Adding pycparser 2.17 to easy-install.pth file

Using /usr/local/lib/python2.7/dist-packages
Finished processing dependencies for torchaudio==0.1

Any idea what went wrong?

Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
soumithcommented, May 7, 2017

you installed torchaudio, but you are running python from a folder where there is a subfolder called torchaudio, so that is being picked up instead.you can change your folder and try again.

cd … python import torchaudio

0reactions
vincentqbcommented, Aug 22, 2019

Edit: ok, for some odd reason, tried to change location of source folder and then your workaround worked. Thanks!

Since this appears to have been resolved, I will close this issue. Please feel free to reopen or create a new one it if it is not the case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot import torchaudio with torch 1.1 · Issue #121 - GitHub
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...
Read more >
Torchaudio import error - audio - PyTorch Forums
The error message indicates a mismatch between the PyTorch version expected by torchaudio and the one installed. Generally, compiling the auxiliary libraries ( ......
Read more >
cannot import torch audio ' No audio backend is available.'
I am using conda on windows 10. I tried to install PySoundFile from conda distribution conda install -c conda-forge pysoundfile but it doesn't ......
Read more >
Problems with torchaudio install in ubuntu 20 and python38
Hi,. Would you mind trying torchaudio==0.9.1? Based on the following link, it's possible that the installed PyTorch is version 1.9.1 rather than ...
Read more >
torchaudio Changelog - pyup.io
Allowed the customization of axis exclusion for ASR head (1932) ... from torchaudio.models.wav2vec2.utils import import_huggingface_model
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