1

I cannot import pandas_datareader due to the following error:

ImportError: cannot import name 'urlencode' from 'pandas.io.common'

How can I solve this problem?

I know that this question has already been asked, for instance here pandas_datareader, ImportError: cannot import name 'urlencode' but the solutions proposed there seem to not worked for me.

It's also possible that I am applying them in the wrong way (see below) but I do not know what I'm doing wrong.

Thank you very much for your help.

Some additional info:

  1. I'm using Python 3.9.1
  2. I have pandas_datareader 0.9 (the most recent version) according to Anaconda but pandas.show_versions() does not find any pandas_datareader module installed
  3. I have pandas 1.2.1 according to Anaconda (checked typing conda list in the terminal); but using the function pandas.show_versions() in the console it says me that I am using pandas 1.2.2 (A clarification also on this point is appreciated)
  4. I have tried (with no success) this solution suggested in a similar question:
import pandas as pd

pd.core.common.is_list_like = pd.api.types.is_list_like

import pandas_datareader
  1. I have also tried (with no success) this other solution suggested in a similar question: replace

from pandas.io.common import urlencode

with


from urllib.parse import urlencode

in the file pandas_datareader/iex/init.py and pandas_datareader/base.py but I have checked the files and they are already correct.

pietrosan
  • 23
  • 5
  • Does this answer your question? [pandas\_datareader, ImportError: cannot import name 'urlencode'](https://stackoverflow.com/questions/63894169/pandas-datareader-importerror-cannot-import-name-urlencode) – TYZ Feb 12 '21 at 14:37
  • No unfortunately it does not. I have tried the solutions proposed there but with no success. – pietrosan Feb 12 '21 at 14:42
  • 1
    Have you tried to reinstall pandas and making sure both are of the latest versions? It might be some compatibility issue. – TYZ Feb 12 '21 at 15:08
  • Yes, I have created a new conda environment in which I have reinstalled pandas_datareader but I have the same problem. – pietrosan Feb 12 '21 at 17:25
  • I just created a fresh conda environment for python3.9.1 and installed pandas-datareader, no issue for me and I'm not getting the error. What is the pandas version you are using? – TYZ Feb 12 '21 at 17:33
  • pandas 1.2.2 and pandas_datareader 0.9, and you? – pietrosan Feb 12 '21 at 21:28
  • Same, so I have no idea what went wrong from all the information you provided and can't reproduce the error. – TYZ Feb 12 '21 at 21:37

0 Answers0