未解决的导入 csv Pydev Eclipse

发布于 2024-12-25 04:35:09 字数 705 浏览 1 评论 0原文

我对 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.

enter image description here

Would someone please help me resolve this as it is most frustrating!

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷爱 2025-01-01 04:35:09

由于您的文件名为 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 you import csv. Rename your file to something like myCsv.py to resolve the ambiguity.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文