Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import pandas results in ModuleNotFoundError :_lzma

On Ubuntu 18.04 with python 3.7.3, I'm attempting to import pandas but this fails because it can't find _lzma.

I've verified that _lzma is installed with dpkg:

/usr/lib/python3.7/lib-dynload/_lzma.cpython-37m-x86_64-linux-gnu.so. Oddly, _lzma is not a dependency of pandas (as specified by pip3).

like image 763
Marco Dalla Gasperina Avatar asked Jul 19 '19 13:07

Marco Dalla Gasperina


People also ask

Why is import pandas as PD not working?

The most frequent source of this error is that you haven't installed Pandas explicitly with pip install pandas . Alternatively, you may have different Python versions on your computer, and Pandas is not installed for the particular version you're using.

How do I import pandas in Python?

Enter the command “pip install pandas” on the terminal. This should launch the pip installer. The required files will be downloaded, and Pandas will be ready to run on your computer. After the installation is complete, you will be able to use Pandas in your Python programs.

Which is the best way to import pandas module?

The easiest way to install pandas is to install it as part of the Anaconda distribution, a cross platform distribution for data analysis and scientific computing. This is the recommended installation method for most users.

What is the difference between import pandas and import pandas as PD?

The import pandas portion of the code tells Python to bring the pandas data analysis library into your current environment. The as pd portion of the code then tells Python to give pandas the alias of pd. This allows you to use pandas functions by simply typing pd. function_name rather than pandas.


1 Answers

I have the same issue using pyenv. You don't need to rollback pandas.

To fix import errors, I've removed python:

$ pyenv uninstall 3.7.1

Installed dependencies:

$ sudo apt-get install liblzma-dev

and reinstalled version:

$ pyenv install 3.7.1

More on this dependencies here

like image 154
kiba Avatar answered Oct 05 '22 21:10

kiba