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?
The problem is that your file is named panda.py, and that's what you actually import.
Related
In Linux Environment I have installed pandas using "pip install pandas"
but when I'm running python and using import pandas for that I'm getting such error
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pandas
Is there anyways which automatically installs pandas library as a part of code in Linux environment
python version is 3.6.6 and pandas_datareader version is 0.7.0
when i import pandas_datareader, an error occurs like below.
C:\PycharmProjects\Demo\venv\Scripts\python.exe C:/PycharmProjects/Demo/stock.py
Traceback (most recent call last):
File "C:/PycharmProjects/Demo/stock.py", line 3, in <module>
import pandas_datareader as wb
File "C:\PycharmProjects\Demo\venv\lib\site-packages\pandas_datareader\__init__.py", line 2, in <module>
from .data import (DataReader, Options, get_components_yahoo,
File "C:\PycharmProjects\Demo\venv\lib\site-packages\pandas_datareader\data.py", line 7, in <module>
from pandas_datareader.av.forex import AVForexReader
File "C:\PycharmProjects\Demo\venv\lib\site-packages\pandas_datareader\av\__init__.py", line 3, in <module>
from pandas_datareader.base import _BaseReader
File "C:\PycharmProjects\Demo\venv\lib\site-packages\pandas_datareader\base.py", line 11, in <module>
from pandas.compat import StringIO, bytes_to_str
ImportError: cannot import name 'StringIO'
can somebody help me?
The problem is pandas 0.25.0 has removed pandas.compat. So go back to 0.24.2
pip install "pandas<0.25.0"
or
pipenv install "pandas<0.25.0"
I ran into the same issue with Python3.6 and Python3.7
Downgraded, and it works fine on Python2.7
Also, saw a comment above that Python3.5 works.
I have some code, preprocess_align.py which runs perfectly on my PC but I get an ImportError when running it on a server. The ImportError supposedly comes when pandas is imported. Here is the error:
Traceback (most recent call last):
File "get_features.py", line 12, in <module>
import preprocess_align as prep
File "/home/influenza/preprocess_align.py", line 7, in <module>
import pandas as pd
File "/home/influenza/anaconda2/lib/python2.7/site-packages/pandas/__init__.py", line 42, in <module>
from pandas.core.api import *
File "/home/influenza/anaconda2/lib/python2.7/site-packages/pandas/core/api.py", line 10, in <module>
from pandas.core.groupby.groupby import Grouper
File "/home/influenza/anaconda2/lib/python2.7/site-packages/pandas/core/groupby/__init__.py", line 2, in <module>
from pandas.core.groupby.groupby import (
File "/home/influenza/anaconda2/lib/python2.7/site-packages/pandas/core/groupby/groupby.py", line 16, in <module>
from pandas import compat
ImportError: cannot import name compat
The Python version is Python 2.7.14 |Anaconda custom (64-bit) and I have already used conda update pandas to update the version to the latest.
Any help is appreciated.
You didn't tell us your pandas version, for 0.25,0.24,0.23 as the doc says about pandas.compat
Warning
The pandas.core, pandas.compat, and pandas.util top-level modules are PRIVATE. Stable functionality in such modules is not guaranteed.
as in 0.23
https://pandas.pydata.org/pandas-docs/version/0.23/api.html?highlight=compat
it seems that downgrade to 0.23 works for me.
you may use
pip uninstall pandas
pip install --upgrade pandas==0.23.0
and in 0.24
https://pandas.pydata.org/pandas-docs/version/0.24/reference/index.html
and in stable(Now 0.25)
https://pandas.pydata.org/pandas-docs/stable/reference/index.html?highlight=compat
I am working on Python 3.5 and I am importing Pandas, Numpy, scikit-learn and pickle libraries in pycharm IDE. I have installed all the libraries as well, via pycharm IDE's package installer. When i execute following commands it gives me no "Syntax" errors in IDE.
import pickle
from pathlib import Path
import numpy as np
import pandas as pd
from sklearn import metrics
from sklearn.cluster import KMeans
When i Execute my code it gives me following error for specifically importing "pandas" library. -->
Traceback (most recent call last):
File "D:/InputFile.py", line 5, in <module>
import pandas as pd
File "C:\Users\sneha\AppData\Local\Temp\InputFile.py\venv\lib\site-packages\pandas\__init__.py", line 42, in <module>
from pandas.core.api import *
File "C:\Users\sneha\AppData\Local\Temp\InputFile.py\venv\lib\site-packages\pandas\core\api.py", line 10, in <module>
from pandas.core.groupby.groupby import Grouper
File "C:\Users\sneha\AppData\Local\Temp\InputFile.py\venv\lib\site-packages\pandas\core\groupby\__init__.py", line 2, in <module>
from pandas.core.groupby.groupby import (
File "C:\Users\sneha\AppData\Local\Temp\InputFile.py\venv\lib\site-packages\pandas\core\groupby\groupby.py", line 49, in <module>
from pandas.core.frame import DataFrame
File "C:\Users\sneha\AppData\Local\Temp\InputFile.py\venv\lib\site-packages\pandas\core\frame.py", line 74, in <module>
from pandas.core.series import Series
File "C:\Users\sneha\AppData\Local\Temp\InputFile.py\venv\lib\site-packages\pandas\core\series.py", line 3978, in <module>
Series._add_series_or_dataframe_operations()
File "C:\Users\sneha\AppData\Local\Temp\InputFile.py\venv\lib\site-packages\pandas\core\generic.py", line 8891, in _add_series_or_dataframe_operations
from pandas.core import window as rwindow
File "C:\Users\sneha\AppData\Local\Temp\InputFile.py\venv\lib\site-packages\pandas\core\window.py", line 36, in <module>
import pandas._libs.window as _window
ImportError: DLL load failed: The specified module could not be found.
I have seached for this and tried different solutions, but could not solve this errors.
Tried Solutions :
The specified module could not be found. DLL load failed
the-specified-module-could-not-be-found-dll-load-failed
the-specified-module-could-not-be-found-dll-load-failed
Try reinstalling pandas by typing this in the command-prompt
pip uninstall pandas
pip install pandas
I had similar problem when I installed pandas 0.23.0
If you are using pandas 0.23.0, uninstall it and re-install 0.22.0
It worked for my case
I'm using Python 3.6.3 on Windows 10 and Quandl module in my pip list, but I get the following error:
import quandl
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import quandl
File "C:\Users\Kamal\AppData\Local\Programs\Python\Python36-32\lib\quandl\__init__.py", line 3, in <module>
from .api_config import ApiConfig
ModuleNotFoundError: No module named 'quandl.api_config'
Try pip3 install quandl. If you have python2 installed, there may be a mismatch in symlinks related to pip.