PyDev:在 Python io.py 之后意外命名文件后无法编译

PyDev: Can't compile after accidentally naming file after Python io.py

所以我不假思索地在我的工作目录中命名了一个文件 io.py。当我尝试编译时出现回溯错误。意识到我所做的事情后,我重命名了我的文件并更新了对它的引用,但我仍然收到以下错误:

Traceback (most recent call last):
  File "C:\Users\Tom\workspace\Converter\get_file.py", line 9, in <module>
    from scipy import complex_
  File "C:\Python27\lib\site-packages\scipy\__init__.py", line 70, in <module>
    from numpy import show_config as show_numpy_config
  File "C:\Python27\lib\site-packages\numpy\__init__.py", line 185, in <module>
    from . import add_newdocs
  File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
    from .type_check import *
  File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 46, in <module>
    from numpy.testing import Tester
  File "C:\Python27\lib\site-packages\numpy\testing\__init__.py", line 13, in <module>
    from .utils import *
  File "C:\Python27\lib\site-packages\numpy\testing\utils.py", line 15, in <module>
    from tempfile import mkdtemp
  File "C:\Python27\lib\tempfile.py", line 32, in <module>
    import io as _io
  File "C:\Users\Tom\workspace\Converter\io.py", line 1, in <module>
    """The io module provides the Python interfaces to stream handling. The
  File "C:\Users\Tom\workspace\Converter\get_file.py", line 9, in <module>
    from scipy import complex_
ImportError: cannot import name complex_

我重启了 PyDev 也没有用。我已经刷新了解释器没有用。

我已按照 this Python issue 中的说明进行操作,但该命令 returns 在我的机器上得到了正确的结果。

tempfile.py 是我可以删除以解决此问题的临时文件吗?

我找到了解决办法。非常简单,但对于落入同样陷阱的其他新手来说,也许值得离开这里。

PyDev 将代码编译成 *.pyc 文件。当您更新引用并重命名文件时,这些文件不会立即重新编译。删除 io.pyc 文件我也允许编译 运行 正确。

我也找到了一些more info on common pitfalls