在导入pandas时报错,但是查询已经安装了pandas库,报错信息如下:
(py36)my@xilinx:~/ytwork/pandas-0.22.0$ pip list | grep pandas
pandas 0.22.0
(py36)my@xilinx:~/ytwork/pandas-0.22.0$ python
Python 3.6.6 | packaged by rpi | (default, Sep 6 2018, 10:56:14)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
Traceback (most recent call last):
File "/home/my/ytwork/pandas-0.22.0/pandas/__init__.py", line 26, in <module>
from pandas._libs import (hashtable as _hashtable,
File "/home/my/ytwork/pandas-0.22.0/pandas/_libs/__init__.py", line 4, in <module>
from .tslib import iNaT, NaT, Timestamp, Timedelta, OutOfBoundsDatetime
ModuleNotFoundError: No module named 'pandas._libs.tslib'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/my/ytwork/pandas-0.22.0/pandas/__init__.py", line 35, in <module>
"the C extensions first.".format(module))
ImportError: C extension: No module named 'pandas._libs.tslib' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first.
根据提示,执行python setup.py build_ext --inplace --force
(py36)my@xilinx:~/ytwork/pandas-0.22.0$ python setup.py build_ext --inplace --force
running build_ext
cythoning pandas/_libs/lib.pyx to pandas/_libs/lib.c
/home/my/.conda/envs/py36/lib/python3.6/site-packages/Cython-0.29.27-py3.6-linux-armv7l.egg/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /home/my/ytwork/pandas-0.22.0/pandas/_libs/lib.pxd
tree = Parsing.p_module(s, pxd, full_module_name)
cythoning pandas/_libs/properties.pyx to pandas/_libs/properties.c
/home/my/.conda/envs/py36/lib/python3.6/site-packages/Cython-0.29.27-py3.6-linux-armv7l.egg/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /home/my/ytwork/pandas-0.22.0/pandas/_libs/properties.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
... ...
编译好后,再次导入pandas,没有报错