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
Related
I just did a conda install of a few packages to follow a tutorial, and now I can't even import pandas.
I installed these:
fake-factory==0.7.2
Faker==0.7.3
pytz==2016.7
tzlocal==1.3.0
And now I get this:
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\__init__.py", line 42, in <module>
from pandas.core.api import *
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\api.py", line 7, in <module>
from pandas.core.arrays.integer import (
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\arrays\__init__.py", line 2, in <module>
from .base import (ExtensionArray, # noqa
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\arrays\base.py", line 21, in <module>
from pandas.core import ops
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\ops\__init__.py", line 21, in <module>
from pandas.core.construction import extract_array
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\construction.py", line 18, in <module>
from pandas.core.dtypes.base import ExtensionDtype, registry
ImportError: cannot import name 'registry' from 'pandas.core.dtypes.base' (C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\dtypes\base.py)
I tried doing a conda update pandas, but to no avail.
I also just installed luigi, not quite sure when it broke as I installed all the additional packages in one go.
Updated version of pandas package using pip3
try this in python3
pip3 install --upgrade pandas
Try updating pandas package in Anaconda:
conda install pandas=1.1.4
If no luck, try updating all packages:
conda update --all
Worked in my case.
I installed librosa, and now im trying to import it
import librosa
This throws me this error for some reason
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\__init__.py", line 12, in <module>
from . import core
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\core\__init__.py", line 125, in <module>
from .time_frequency import * # pylint: disable=wildcard-import
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\core\time_frequency.py", line 11, in <module>
from ..util.exceptions import ParameterError
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\util\__init__.py", line 77, in <module>
from .utils import * # pylint: disable=wildcard-import
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\util\utils.py", line 15, in <module>
from .decorators import deprecated
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\util\decorators.py", line 9, in <module>
from numba.decorators import jit as optional_jit
ModuleNotFoundError: No module named 'numba.decorators'
Why am i getting this error even after installing the library?
You have to install numbra version 0.48 because of a bug, run
pip install numba==0.48
Librosa Issue on Github
You need to use any numba version before 0.8.0
However, the most recent librosa is not compatible with any numba below 0.48.
At least, that's what I've found from using it on Windows. My solution was to use google colaboratory as it didn't give me any error when importing librosa.
I've got the exact error. Solved it with
pip uninstall --yes librosa
pip install librosa --force-reinstall
Your python version should be 3.8.
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 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'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.