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.

ModuleNotFoundError: No module named '_lzma'

See original GitHub issue

🐛 Bug

Importing the latest version of torchvision==0.8.1 throws following error:

  File "tor-example.py", line 2, in <module>
    import torchvision
  File "/home/zoran/MyProjects/mindsdb-examples/tor/lib/python3.7/site-packages/torchvision/__init__.py", line 7, in <module>
    from torchvision import datasets
  File "/home/zoran/MyProjects/mindsdb-examples/tor/lib/python3.7/site-packages/torchvision/datasets/__init__.py", line 6, in <module>
    from .mnist import MNIST, EMNIST, FashionMNIST, KMNIST, QMNIST
  File "/home/zoran/MyProjects/mindsdb-examples/tor/lib/python3.7/site-packages/torchvision/datasets/mnist.py", line 11, in <module>
    import lzma
  File "/usr/local/lib/python3.7/lzma.py", line 27, in <module>
    from _lzma import *
ModuleNotFoundError: No module named '_lzma'

To Reproduce

Steps to reproduce the behavior:

  1. pip install torchvision
  2. import torchvision

Environment

CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A

OS: Ubuntu 19.10 (x86_64)
GCC version: (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008
Clang version: Could not collect
CMake version: version 3.13.4

Python version: 3.7 (64-bit runtime)
Is CUDA available: False
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.19.2
[pip3] torch==1.7.0
[pip3] torchvision==0.8.1
[conda] Could not collect
  • PyTorch / torchvision Version (1.7.0 / 0.8.1):
  • OS : Linux Ubuntu
  • How you installed PyTorch / torchvision (conda, pip, source): pip
  • Python version: 3.7.3

cc @pmeier

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16

github_iconTop GitHub Comments

13reactions
rvoriascommented, Apr 1, 2021

Hi, I came across this issue after installing python from source. It seems that I installed python without liblzma-dev. After installing liblzma-dev and installing python again, the import error was gone.

2reactions
INF800commented, May 12, 2022

Thus issue occurs in 3.10 but not in 3.7 for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No module named '_lzma' when building python using pyenv ...
The reason is that the module you're trying to use is implemented in C ... <module> from _lzma import * ModuleNotFoundError: No module...
Read more >
ModuleNotFoundError: No module named '_lzma' #27532
Can't import last pandas release (0.25.0). I've installed pandas using pipenv : $ pipenv --three $ pipenv shell [pandas-lzma ...
Read more >
ModuleNotFoundError: No module named '_lzma' - vision
This means that the torchvision I have is broken or buggy. Can someone suggest a fix for this error. If u need a...
Read more >
no module named '_lzma' when import torchvision ... - CodeThief
In my case, uninstall my current python version and install xz using homebrew and reinstall the python version that I removed. pyenv uninstall ......
Read more >
ModuleNotFoundError: No module named 'pycopy-lzma'
Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pycopy-lzma' How to remove the Module.
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