45
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Python3】pandasのversion0.25.0でimportエラーが起きる

Last updated at Posted at 2019-08-04

現時点(2019/08/04)で最新のpandasをinstallすると,version0.25.0がインストールされる.

ただそのままpandasをimportするとエラーがでたので共有します.

環境

ec2 amazon-linux2
python 3.6.8

エラー文

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

いろいろ試しましたが,うまく行かず..

解決策

なので現時点ではpandasのversionを1つ下げてinstallするといいです.(本質的な解決ではありませんが)

pip install pandas==0.24.1
>>> import pandas as pd
>>> 

これでしばらくはなんとかなります.version0.25.0での本質的な対処法がわかり次第,またここで共有させていただきます.

追記(20200207)

@nakkun さんからコメントをいただきまして,

pyenvの再インストール後,

pyenv uninstall 3.6.8
sudo yum install -y xz-devel # macの場合は brew install xz
pyenv install 3.6.8

で解決します.

macの場合のソースは以下

45
24
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
45
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?