Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
24
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

posted at

updated at

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

現時点(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の場合のソースは以下

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
24
Help us understand the problem. What are the problem?