Python3.6 Pandas"无法导入DataFrame"

时间:2017-08-08 17:31:56

标签: python pandas dataframe

我在使用Python3.6和pandas来读取csv数据时遇到了问题。 一切正常,然后我在Arch安装上进行了系统更新

sudo pacman -Syu

然后当尝试运行导入pandas的任何脚本时,我收到以下错误:

  from .sqldf import *
  File "/usr/lib/python3.6/site-packages/pandasql/sqldf.py", line 3, in <module>
  from pandas.io.sql import to_sql, read_sql
  File "/usr/lib/python3.6/site-packages/pandas/io/sql.py", line 23, in <module>
  from pandas.core.api import DataFrame, Series
  ImportError: cannot import name 'DataFrame'

导入pandas的任何代码都会出现此错误,例如:

import pandas
print ('Hello')

所以这是大熊猫的问题,但我似乎无法在任何地方找到原因的根源。任何有关此问题的帮助将不胜感激!

完全错误:

        from pandas import DataFrame
  File "/usr/lib/python3.6/site-packages/pandas/__init__.py", line 42, in <module>
    from pandas.core.api import *
  File "/usr/lib/python3.6/site-packages/pandas/core/api.py", line 10, in <module>
    from pandas.core.groupby import Grouper
  File "/usr/lib/python3.6/site-packages/pandas/core/groupby.py", line 49, in <module>
    from pandas.core.frame import DataFrame
  File "/usr/lib/python3.6/site-packages/pandas/core/frame.py", line 67, in <module>
    from pandas.core.generic import NDFrame, _shared_docs
  File "/usr/lib/python3.6/site-packages/pandas/core/generic.py", line 49, in <module>
    from pandas.io.formats.format import format_percentiles, DataFrameFormatter
  File "/usr/lib/python3.6/site-packages/pandas/io/formats/format.py", line 35, in <module>
    from pandas.io.common import (_get_handle, UnicodeWriter, _expand_user,
  File "/usr/lib/python3.6/site-packages/pandas/io/common.py", line 4, in <module>
    import csv
  File "/home/knation/ML/dataScience/DataWrangling/csv.py", line 2, in <module>
    import pandasql
  File "/usr/lib/python3.6/site-packages/pandasql/__init__.py", line 1, in <module>
    from .sqldf import *
  File "/usr/lib/python3.6/site-packages/pandasql/sqldf.py", line 3, in <module>
    from pandas.io.sql import to_sql, read_sql
  File "/usr/lib/python3.6/site-packages/pandas/io/sql.py", line 23, in <module>
    from pandas.core.api import DataFrame, Series
ImportError: cannot import name 'DataFrame'

这也可能与我最近的pacman日志有关,是否有任何想法可能导致问题?

[2017-08-08 10:38] [PACMAN] Running 'pacman -Syu'
[2017-08-08 10:38] [PACMAN] synchronizing package lists
[2017-08-08 10:38] [PACMAN] starting full system upgrade
[2017-08-08 10:43] [ALPM] transaction started
[2017-08-08 10:43] [ALPM] upgraded attr (2.4.47-2 -> 2.4.47-3)
[2017-08-08 10:43] [ALPM] upgraded acl (2.2.52-3 -> 2.2.52-4)
[2017-08-08 10:43] [ALPM] upgraded avr-binutils (2.28-1 -> 2.29-1)
[2017-08-08 10:43] [ALPM] upgraded bridge-utils (1.6-1 -> 1.6-2)
[2017-08-08 10:43] [ALPM] upgraded pango (1.40.7-1 -> 1.40.8-1)
[2017-08-08 10:43] [ALPM] upgraded libxkbcommon (0.7.1-1 -> 0.7.2-1)
[2017-08-08 10:43] [ALPM] upgraded gtk-update-icon-cache (3.22.17-1 -> 3.22.18-1)
[2017-08-08 10:43] [ALPM] upgraded libsystemd (234.11-3 -> 234.11-4)
[2017-08-08 10:43] [ALPM] upgraded gtk3 (3.22.17-1 -> 3.22.18-1)
[2017-08-08 10:43] [ALPM] upgraded e2fsprogs (1.43.4-1 -> 1.43.5-1)
[2017-08-08 10:43] [ALPM] upgraded systemd (234.11-3 -> 234.11-4)
[2017-08-08 10:43] [ALPM] upgraded sqlite (3.19.3-1 -> 3.20.0-1)
[2017-08-08 10:43] [ALPM] upgraded chromium (60.0.3112.78-1 -> 60.0.3112.90-1)
[2017-08-08 10:43] [ALPM] upgraded ffmpeg (1:3.3.2-2 -> 1:3.3.3-1)
[2017-08-08 10:43] [ALPM] upgraded firefox (54.0.1-1 -> 55.0-1)
[2017-08-08 10:43] [ALPM] upgraded geoip-database (20170704-1 -> 20170801-1)
[2017-08-08 10:43] [ALPM] upgraded perl-error (0.17024-2 -> 0.17025-1)
[2017-08-08 10:43] [ALPM] upgraded git (2.13.3-2 -> 2.14.0-1)
[2017-08-08 10:43] [ALPM] upgraded glew (2.0.0-1 -> 2.1.0-1)
[2017-08-08 10:43] [ALPM] upgraded gnupg (2.1.21-3 -> 2.1.22-1)
[2017-08-08 10:43] [ALPM] upgraded gparted (0.28.1-1 -> 0.28.1-2)
[2017-08-08 10:43] [ALPM] upgraded linux (4.12.3-1 -> 4.12.4-1)
[2017-08-08 10:43] [ALPM-SCRIPTLET] >>> Updating module dependencies. Please wait ...
[2017-08-08 10:43] [ALPM] upgraded linux-headers (4.12.3-1 -> 4.12.4-1)
[2017-08-08 10:43] [ALPM] upgraded linux-lts (4.9.40-1 -> 4.9.41-1)
[2017-08-08 10:43] [ALPM-SCRIPTLET] >>> Updating module dependencies. Please wait ...
[2017-08-08 10:43] [ALPM] upgraded linux-lts-headers (4.9.40-1 -> 4.9.41-1)
[2017-08-08 10:43] [ALPM] upgraded python-prompt_toolkit (1.0.14-1 -> 1.0.15-1)
[2017-08-08 10:43] [ALPM] upgraded s-nail (14.9.0-1 -> 14.9.3-1)
[2017-08-08 10:43] [ALPM] upgraded systemd-sysvcompat (234.11-3 -> 234.11-4)
[2017-08-08 10:43] [ALPM] upgraded vim-runtime (8.0.0722-1 -> 8.0.0851-1)
[2017-08-08 10:43] [ALPM] upgraded vim (8.0.0722-1 -> 8.0.0851-1)

注意:如果我在Python终端中运行,似乎没有问题,只有脚本。

Shown is the import working in Python terminal but failing when ran in the simple script shown it errors out.

1 个答案:

答案 0 :(得分:0)

所以这是浪费时间,这个错误似乎与我用来测试的脚本无关。一旦我将它移出目录,它就一切正常。