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.
Related
One of my script is importing Investpy library and I encoutered the following error message when I have checked the site-package the Investpy is in place.
Traceback (most recent call last):
File "/Users/LSH/WSFG_DEV/workspace/telegram_bot/roe_eps_check.py", line 9, in <module>
import investpy
File "/Users/LSH/Library/Python/3.8/lib/python/site-packages/investpy/__init__.py", line 7, in <module>
from .stocks import get_stocks, get_stocks_list, get_stocks_dict, get_stock_countries, get_stock_recent_data, \
File "/Users/LSH/Library/Python/3.8/lib/python/site-packages/investpy/stocks.py", line 16, in <module>
from lxml.html import fromstring
File "/Users/LSH/Library/Python/3.8/lib/python/site-packages/lxml/html/__init__.py", line 53, in <module>
from .. import etree
ImportError: cannot import name 'etree' from 'lxml' (/Users/LSH/Library/Python/3.8/lib/python/site-packages/lxml/__init__.py)
LSH#LSHs-Air workspace %
Does anyone know what is wrong? I have already remove and re-install Investpy but no luck.
Thank you everyone!! :)
You could try and do:
pip install lxml-4.6.3-cp38-cp38-win_amd64
OR
python -m pip install lxml==3.6.0
If this doesn't fix the issue, uninstall lxml and reinstall it using pip
Source:
ImportError: cannot import name 'etree' on Python 3.6
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.
So I am trying to install zipline and zipline live. I have installed all of the main packages needed for this, and when I do pip install zipline I get no errors. But then when I go into python and do import zipline I get the error:
>>> import zipline
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Benito\AppData\Local\Programs\Python\Python36\lib\site-packages\zipline\__init__.py", line 20, in <module>
from . import data
File "C:\Users\Benito\AppData\Local\Programs\Python\Python36\lib\site-packages\zipline\data\__init__.py", line 1, in <module>
from . import loader
File "C:\Users\Benito\AppData\Local\Programs\Python\Python36\lib\site-packages\zipline\data\loader.py", line 20, in <module>
from pandas_datareader.data import DataReader
File "C:\Users\Benito\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas_datareader\__init__.py", line 2, in <module>
from .data import (
File "C:\Users\Benito\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas_datareader\data.py", line 9, in <module>
from pandas.util._decorators import deprecate_kwarg
ModuleNotFoundError: No module named 'pandas.util._decorators'
I have tired pip install pandas.util._decorators but this has not worked. I also tried changing to a more up-to-date pandas, but zipline and zipline live do not support this . Right now I have pandas 0.18.1
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
Here is my error:
Traceback (most recent call last):
File "./convert.py", line 6, in <module>
import openpyxl # from https://pythonhosted.org/openpyxl/ or PyPI (e.g. via pip)
ImportError: No module named openpyxl
i have installed the python package openpyxl but this error still appear
Im using linux python version 2.6.6
any help please
i got this new error when i ran the python2.7 script.py:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip import main
File "/usr/local/lib/python2.7/site-packages/pip/__init__.py", line 13, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 15, in <module>
import zipfile
File "/usr/local/lib/python2.7/zipfile.py", line 6, in <module>
import io
File "/usr/local/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: /usr/local/lib/python2.7/lib-dynload/_io.so: undefined symbol: _PyErr_ReplaceException
openpyxl module has 2 dependent modules : 1. jdcal 2. et_xmlfile
I was able to install openpyxl module and this is what I did :
1.Downloaded the openpyxl,jdcal and et_xmlfile from https://pypi.python.org/pypi and saved jdcal-1.0.tar.gz, et_xmlfile-1.0.0.tar.gz,openpyxl-2.3.0-b2.tar.gz in a local folder in my system.
2.Then I ran the commands in the following order :
pip install jdcal-1.0.tar.gz
pip install et_xmlfile-1.0.0.tar.gz
pip install openpyxl-2.3.0-b2.tar.gz
openpyxl got successfully after this. Please check whether this helps.