未解决的导入 csv Pydev Eclipse
我对 Eclipse 上的 Pydev 又爱又恨。由于某种原因,它现在告诉我它在代码上有一个未解决的导入:
import csv
Traceback (most recent call last):
File "/Users/peterstannett/Documents/Programming/python/eclipse/workspace/myFirstPydev/csv.py", line 1, in <module>
import csv
File "/Users/peterstannett/Documents/Programming/python/eclipse/workspace/myFirstPydev/csv.py", line 3, in <module>
cr = csv.reader(f)
AttributeError: 'module' object has no attribute 'reader'
我确信几天前它工作正常!
因此,我开始查看解释器和 csv.py 文件所在的路径,我可以在系统 PYTHONPATH 中看到它具有保存 csv.py 文件的 /lib/python2.7 但我仍然得到一个错误。
有人可以帮我解决这个问题吗,因为这是最令人沮丧的!
谢谢
I have a love-hate relationship with Pydev on Eclipse. For some reason it is now telling me that it has an unresolved import on the code:
import csv
Traceback (most recent call last):
File "/Users/peterstannett/Documents/Programming/python/eclipse/workspace/myFirstPydev/csv.py", line 1, in <module>
import csv
File "/Users/peterstannett/Documents/Programming/python/eclipse/workspace/myFirstPydev/csv.py", line 3, in <module>
cr = csv.reader(f)
AttributeError: 'module' object has no attribute 'reader'
It was working fine a few days ago I'm sure!
So I started to look at the interpreter and the path where the csv.py file should be and I can see in the System PYTHONPATH that it has the /lib/python2.7 where the csv.py file is held yet I still get an error.
Would someone please help me resolve this as it is most frustrating!
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您的文件名为
csv.py
,因此当您导入 csv
时,它会在标准库中的 csv 模块之前找到。将文件重命名为myCsv.py
之类的名称以解决歧义。Since your file is called
csv.py
, it is found before the csv module from the standard library when youimport csv
. Rename your file to something likemyCsv.py
to resolve the ambiguity.