Python - 无法找到文件

时间:2013-01-30 21:52:58

标签: python

我的项目中有一个名为fileimporter.py的文件,当运行该项目时,它会引发以下错误:

Traceback (most recent call last):
  File "C:\Users\myuser\Desktop\python\project\samples\clientlogin_example.py", line 54, in <module>
    CSVImporter(ft_client).importFile("data.csv")
  File "build\bdist.win-amd64\egg\fusiontables\fileimport\fileimporter.py", line 39, in importFile
ValueError: invalid literal for int() with base 10: '1S762e1A1XD1R97hy2LDgokzWo4fw_YWgUPbptlc'

在我的班级的顶部,我有下面的行与项目的结构相对应:

from project.fileimport.fileimporter import CSVImporter

问题是,我找不到路径“build \ bdist.win-amd64 \ egg \”,即使我删除该文件或尝试修复它或清理并重建项目,仍然会引发相同的错误。

它似乎是一个缓存文件,因为我删除了发生错误的行,但控制台中没有任何更改...

有人知道我怎么能找到那条路吗?

谢谢

1 个答案:

答案 0 :(得分:0)

这听起来很像遗留pyc文件。 e.g:

$ echo "def f(): raise Exception('footastic')" > foo.py
$ python -c "import foo"
$ python -c "import foo; foo.f()"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "foo.py", line 1, in f
    def f(): raise Exception('footastic')
Exception: footastic

现在让我们删除foo.py并再试一次:

$ rm foo.py
$ python -c "import foo"
$ python -c "import foo; foo.f()"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "foo.py", line 1, in f
Exception: footastic

删除左侧foo.pyc使其恢复正常:

$ rm foo.pyc
$ python -c "import foo"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named foo