当我从命令行调用脚本时,Pandas导入失败。我无法确定造成这种情况的原因。谁能帮我吗?提前谢谢!
代码
import pandas as pd
错误
root@vultr:~/Repos/solomon# python3 lib/scripts/dummy.py
Traceback (most recent call last):
File "lib/scripts/dummy.py", line 1, in <module>
import pandas as pd
File "/usr/local/lib/python3.5/dist-packages/pandas/__init__.py", line 42, in <module>
from pandas.core.api import *
File "/usr/local/lib/python3.5/dist-packages/pandas/core/api.py", line 10, in <module>
from pandas.core.groupby import Grouper
File "/usr/local/lib/python3.5/dist-packages/pandas/core/groupby.py", line 50, in <module>
from pandas.core.frame import DataFrame
File "/usr/local/lib/python3.5/dist-packages/pandas/core/frame.py", line 69, in <module>
from pandas.core.generic import NDFrame, _shared_docs
File "/usr/local/lib/python3.5/dist-packages/pandas/core/generic.py", line 48, in <module>
from pandas.io.formats.format import format_percentiles, DataFrameFormatter
File "/usr/local/lib/python3.5/dist-packages/pandas/io/formats/format.py", line 36, in <module>
from pandas.io.common import (_get_handle, UnicodeWriter, _expand_user,
File "/usr/local/lib/python3.5/dist-packages/pandas/io/common.py", line 484, in <module>
def UnicodeReader(f, dialect=csv.excel, encoding="utf-8", **kwds):
AttributeError: module 'csv' has no attribute 'excel'
答案 0 :(得分:1)
你是否打断了熊猫安装?
尝试升级
(如果你没有,先安装点子) https://pip.pypa.io/en/stable/installing/
然后
pip install pandas --upgrade
答案 1 :(得分:1)
解决:
这是因为我在运行脚本所在的目录中有一个名为“csv”的目录。愚蠢的错误。对不起男人和女孩。