PyCharm,有些软件包无法导入Pandas,ImportError:C扩展名:StringIO未构建

Ale*_* S 4 python pycharm python-2.7 pandas

我有一个非常奇怪的错误,无法解决它.

我有一个具有以下目录结构的项目:

ptouch/
    ptouch/
        __init__.py
        ptouch.py
        io.py
    tests/
        __init__.py
        tests.py
Run Code Online (Sandbox Code Playgroud)

我正在使用PyCharm社区版和Anaconda python发行版.

该文件:ptouch.py包含以下代码:

__author__ = 'foo'
import pandas as pd
df = pd.DataFrame()
Run Code Online (Sandbox Code Playgroud)

执行此文件会出现以下错误:

C:\Anaconda\python.exe ~/ptouch.py
Traceback (most recent call last):
  File "~/ptouch.py", line 2, in <module>
    import pandas as pd
File "C:\Anaconda\lib\site-packages\pandas\__init__.py", line 13, in <module>
  "extensions first.".format(module))
ImportError: C extension: StringIO not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.
Run Code Online (Sandbox Code Playgroud)

但是,执行tests.py没有错误并且使用pandas没有问题.

该文件tests.py包含以下代码:

from unittest import TestCase
import pandas as pd
class Tests(TestCase):
    def test_pickle(self):
        d = pd.DataFrame(np.random.rand(50, 10))
        self.fail()
Run Code Online (Sandbox Code Playgroud)

我试过用conda和pip卸载并重新安装pandas无济于事.创建一个新项目似乎能够毫无问题地加载pandas.我找不到任何可能导致此错误的程序包特定设置.

是否有某些原因导致某些软件包或运行配置尝试从源代码或其他东西运行pandas?当代码被绝对删除?

Ale*_* S 6

它在同一个包中有一个名为'io.py'的文件,因为导入pandas的东西会严重破坏.

不要说出事情 io.py