简体   繁体   中英

How to fix "ModuleNotFoundError: No module named '_lzma' " issue in google cloud console

This is the error I am getting:

Traceback (most recent call last):
  File "reader.py", line 5, in <module>
    import pandas as pd
  File "/usr/local/lib/python3.7/site-packages/pandas/__init__.py", line 55, in <module>
    from pandas.core.api import (
  File "/usr/local/lib/python3.7/site-packages/pandas/core/api.py", line 24, in <module>
    from pandas.core.groupby import Grouper, NamedAgg
  File "/usr/local/lib/python3.7/site-packages/pandas/core/groupby/__init__.py", line 1, in <module>
    from pandas.core.groupby.generic import (  # noqa: F401
File "/usr/local/lib/python3.7/site-packages/pandas/core/groupby/generic.py", line 44, in <module>
    from pandas.core.frame import DataFrame
  File "/usr/local/lib/python3.7/site-packages/pandas/core/frame.py", line 88, in <module>
    from pandas.core.generic import NDFrame, _shared_docs
  File "/usr/local/lib/python3.7/site-packages/pandas/core/generic.py", line 71, in <module>
    from pandas.io.formats.format import DataFrameFormatter, format_percentiles
  File "/usr/local/lib/python3.7/site-packages/pandas/io/formats/format.py", line 47, in <module>
    from pandas.io.common import _expand_user, _stringify_path
  File "/usr/local/lib/python3.7/site-packages/pandas/io/common.py", line 9, in <module>
    import lzma
  File "/usr/local/lib/python3.7/lzma.py", line 27, in <module>
from _lzma import *
ModuleNotFoundError: No module named '_lzma'
Traceback (most recent call last):
  File "server.py", line 9, in <module>
    from search import Search
  File "/home/n_pawar0414/20deg-c/search.py", line 6, in <module>
    import pandas as pd
  File "/usr/local/lib/python3.7/site-packages/pandas/__init__.py", line 55, in <module>
    from pandas.core.api import (
  File "/usr/local/lib/python3.7/site-packages/pandas/core/api.py", line 24, in <module>
    from pandas.core.groupby import Grouper, NamedAgg
  File "/usr/local/lib/python3.7/site-packages/pandas/core/groupby/__init__.py", line 1, in <module>
from pandas.core.groupby.generic import (  # noqa: F401
  File "/usr/local/lib/python3.7/site-packages/pandas/core/groupby/generic.py", line 44, in <module>
    from pandas.core.frame import DataFrame
  File "/usr/local/lib/python3.7/site-packages/pandas/core/frame.py", line 88, in <module>
    from pandas.core.generic import NDFrame, _shared_docs
  File "/usr/local/lib/python3.7/site-packages/pandas/core/generic.py", line 71, in <module>
    from pandas.io.formats.format import DataFrameFormatter, format_percentiles
  File "/usr/local/lib/python3.7/site-packages/pandas/io/formats/format.py", line 47, in <module>
    from pandas.io.common import _expand_user, _stringify_path
  File "/usr/local/lib/python3.7/site-packages/pandas/io/common.py", line 9, in <module>
import lzma
  File "/usr/local/lib/python3.7/lzma.py", line 27, in <module>
    from _lzma import *
ModuleNotFoundError: No module named '_lzma'

I have attempted to install pyenv as well as uninstall python and reinstall it with no luck

The code works on my laptop just fine and runs with no error, i only have the error when running my code on google cloud shell.

The requirements I have installed are:

pandas==0.25.0
nose==1.3.7
tornado==6.0.3
numpy==1.17.0
nltk==3.4.4
pyspellchecker==0.5.0
tqdm==4.32.2
ujson==1.35
cachetools==3.1.1
flask==1.1.1
flask_cors==3.0.8
gevent==1.4.0
openpyxl==2.6.2
xlrd==1.2.0


The issue is that there is no module named _lzma present in/on google cloud console

如果您使用的是 cloud shell,这是一种预期行为,因为 cloud shell vms 是短暂的并且不准备像完整的开发环境一样工作,因此 python 安装不完整,您可以使用计算引擎始终免费的实例来获得尝试您的代码的小型且不可抢占的实例。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM