简体   繁体   English

Python3.6熊猫“无法导入DataFrame”

[英]Python3.6 Pandas “cannot import DataFrame”

I have an issue with using Python3.6 and pandas to read csv data. 我在使用Python3.6和熊猫读取csv数据时遇到问题。 Everything was working fine then I did a system update on my Arch install 一切正常,然后在Arch安装中进行了系统更新

sudo pacman -Syu

Then when trying to run any script with pandas imported I got the following error: 然后,当尝试使用导入的熊猫运行任何脚本时,出现以下错误:

  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'

I get this error with any code importing pandas, such as: 任何导入熊猫的代码都会出现此错误,例如:

import pandas
print ('Hello')

So it it an issue with pandas, but I cannot seem to find the root of the cause online anywhere. 因此,这是大熊猫的问题,但我似乎无法在任何地方在线找到原因的根源。 Any help with this problem would be greatly appreciated! 任何有关此问题的帮助将不胜感激!

Full Error: 完全错误:

        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'

This may also be relevant, my most recent pacman log, any idea if any of these changes could have caused the problem? 我最近的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)

Note: If I run in a Python terminal it seems there are no issues, just the script. 注意:如果我在Python终端中运行,似乎没有问题,只有脚本。

Shown is the import working in Python terminal but failing when ran in the simple script shown it errors out. 显示的是在Python终端中运行的导入,但是在显示错误的简单脚本中运行失败。

So this was a big waste of time, the error seemed to have nothing to do with the script that I was using to test. 因此,这是浪费大量时间,该错误似乎与我用来测试的脚本无关。 Once I moved it out of the directory it was in everything worked fine. 一旦将其移出目录,一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM