I have a very strange error and I can’t solve it.
I have a project with the following directory structure:
ptouch/
ptouch/
__init__.py
ptouch.py
io.py
tests/
__init__.py
tests.py
I am using PyCharm community publication and Anaconda python distribution.
File: ptouch.py
contains the following code:
__author__ = 'foo'
import pandas as pd
df = pd.DataFrame()
Executing this file gives the following error:
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.
However, execution tests.py
does not give errors and uses pandas without problems.
The file tests.py
contains the following code:
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()
I tried to remove and reinstall pandas from both the condos and pipes to no avail. Creating a new project seems to be able to load pandas without any problems. I can not find any specific package parameters that may lead to this error.
, pandas - ? ?