pytorch使用问题

警告
本文最后更新于 2022-12-11,文中内容可能已过时。

1.ModuleNotFoundError: No module named ‘_lzma’

Ubuntu

(1)安装依赖

1
2
apt-get install liblzma-dev -y
pip install backports.lzma

(2)打开lzma.py

1
vim ~/a/b/python3.7/lzma.py

(3)修改代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#修改前
from _lzma import *
from _lzma import _encode_filter_properties, _decode_filter_properties

#修改后
try:
    from _lzma import *
    from _lzma import _encode_filter_properties, _decode_filter_properties
except ImportError:
    from backports.lzma import *
    from backports.lzma import _encode_filter_properties, _decode_filter_properties
0%