3

I am trying to plot in metpy with the help of "xarray with MetPy Tutorial". For that, I am getting error when am running following modules in:

'import cartopy.crs as crs'
'import cartopy.feature as cfeature'
'import matplotlib.pyplot as plt'
'import xarray as xr'
'import metpy.calc as mpcalc'
'from metpy.testing import get_test_data'
'from metpy.units import units.'

ModuleNotFoundError: No module named '_lzma'

like those errors will appear so anyone help me.

Thanks in Advance.

barbsan
  • 3,418
  • 11
  • 21
  • 28
sai nani
  • 31
  • 1
  • 2

4 Answers4

0

This appears to be an issue with your Python build, rather than with MetPy, as _lzma is part of the standard library. From a quick Google search, it seems like this may be an issue with Ubuntu? At any rate, if you google the error, you'll find quite a few solutions to this issue, depending on what your operating system is. We suggest using the Anaconda distribution of Python (https://www.anaconda.com/distribution/), which is easy to set up, and haven't had anyone report this issue before using that stack.

zbruick
  • 316
  • 1
  • 9
0

I experienced this error with python 3.7.3 as well. Switching to Python 3.6.5 :: Anaconda, Inc. solved my problem.

Quinn Vissak
  • 131
  • 1
  • 8
0

I just ran into the same error and blogged about it here. Basically the underscore in the module name hints that it is a module written in C or C++. The reason it is missing from your system is most likely because of a missing system dependencies during installation of the python interpreter. If you installed Python with pyenv they have documented which dependencies should be installed by plattform. Conda does not have that particular problem as it ships with binary dependencies.

Carl Düvel
  • 1,029
  • 9
  • 17
0

I had installed backports.lzma via pip after installing debian packages such as liblzma-dev and assorted build tools, but it would continue to fail to find the module.

I fixed it by adding a fallback import:

try:
    import lzma
except ImportError:
    import backports.lzma as lzma

Using python 3.7.

NuclearPeon
  • 5,743
  • 4
  • 44
  • 52