简体   繁体   English

无法导入熊猫模块; python从较旧的python会话中打印AttributeError

[英]Unable to import pandas module; python prints AttributeError from older python session

I have a weird issue. 我有一个奇怪的问题。 Whenever I import pandas, I get an AttributeError : 每当我导入熊猫时,都会得到AttributeError

import pandas as pd
AttributeError: 'module' object has no attribute 'read_sql_query'

That error message is from an old python session when I was playing around with pandas. 该错误消息来自我在和熊猫玩耍时的旧python会话。 I'm now unable to load pandas as all, I just get that attribute error. 我现在无法全部加载熊猫,我只是遇到了该属性错误。 Here's the full stacktrace: 这是完整的堆栈跟踪:

>>> import pandas as pd
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tsd/p19/home/p19-jonasmst/.local/lib/python2.7/site-packages/pandas/__init__.py", line 13, in <module>
    __import__(dependency)
  File "/cluster/software/VERSIONS/python_packages-2.7_3/cluster/software/VERSIONS/python2-2.7.9/lib/python2.7/site-packages/pytz/__init__.py", line 29, in <module>
    from pkg_resources import resource_stream
  File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 74, in <module>
  File "parser.py", line 12, in <module>
    asid_occurrences = pd.read_sql_query(sql_find_asid_occurrences, db)
AttributeError: 'module' object has no attribute 'read_sql_query'

Possibly relevant info: 可能相关的信息:

  • I'm on a cluster and have to load python2 as a module in order to import pandas. 我在集群上,必须加载python2作为模块才能导入熊猫。
  • I'm logged in to a Linux VM on the cluster through a Thinlinc client (via FireFox), from which I'm again SSHed into another Linux VM. 我通过Thinlinc客户端(通过FireFox)登录到群集上的Linux VM,从中我再次通过SSH登录到另一个Linux VM。
  • I've tried module purge and then module load python2 again, to no avail. 我试过module purge ,然后再次module load python2 ,无济于事。
  • I've tried to log out from the VM and back in again, to no avail. 我尝试从虚拟机注销,然后再次登录,无济于事。
  • I was using VIM when I first got the AttributeError . 我第一次获得AttributeError时就在使用VIM。

Anyone have any idea what's going on here? 有人知道这是怎么回事吗? Thanks! 谢谢!

Update: This seems to happen only when I'm in the directory where I got the error earlier. 更新:这似乎仅在我之前出现错误的目录中时才发生。 Moving to another directory allows me to import pandas just fine. 移到另一个目录后,我就可以导入大熊猫了。 There are no hidden files or anything in that directory, though, so I don't understand what's going on here. 但是,该目录中没有隐藏的文件或任何内容,因此我不知道这里发生了什么。

The problem was that my script was called parser.py which probably conflicts with something in pandas. 问题在于我的脚本名为parser.py ,它可能与熊猫中的某些内容冲突。 Similar issue. 类似的问题。

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

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