Search code examples
pythonpandasql

Cannot import Pandasql in Python 2.7


I've just installed a fresh version of Python 2.7.11 via Anaconda and installed pandas 0.17.1 and pandasql 0.6.3.

Whenever I enter the python IDE and type:

import pandas

Or

import pandasql

I receive the following message:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pandas.py", line 1, in <module>
import pandasql
File "/Users/kenkehoe/anaconda/envs/python2/lib/python2.7/site-packages/pandasql/__init__.py", line 1, in <module>
from .sqldf import sqldf
File "/Users/kenkehoe/anaconda/envs/python2/lib/python2.7/site-packages/pandasql/sqldf.py", line 4, in <module>
from pandas.io.sql import to_sql, read_sql
ImportError: No module named io.sql

Everything seems dependent on this pandas.io.sql module. I've tried uninstalling Pandas and reinstalling and using pip instead of Anaconda, but nothing seems to work.

Any ideas on how to successfully import pandasql?


Solution

  • The problem is that your file is named panda.py, and that's what you actually import.