-1

I am trying to import pandas into my program to make a financial program, and my code looks like so (My IDE is PyCharm)-

from pandas_datareader import data
import matplotlib.pyplot as plt
import pandas as pd

However, when I try to run the code, I get this error message-

Traceback (most recent call last):
File "/Users/benjamin/PycharmProjects/pandas/venv/pandas.py", line 1, in <module>
from pandas_datareader import data
File "/Users/benjamin/PycharmProjects/pandas/venv/lib/python2.7/site- 
packages/pandas_datareader/__init__.py", line 2, in <module>
from .data import (DataReader, Options, get_components_yahoo,
File "/Users/benjamin/PycharmProjects/pandas/venv/lib/python2.7/site-packages/pandas_datareader/data.py", line 7, in <module>
from pandas_datareader.av.forex import AVForexReader
File "/Users/benjamin/PycharmProjects/pandas/venv/lib/python2.7/site-packages/pandas_datareader/av/__init__.py", line 3, in <module>
from pandas_datareader.base import _BaseReader
File "/Users/benjamin/PycharmProjects/pandas/venv/lib/python2.7/site-packages/pandas_datareader/base.py", line 7, in <module>
import pandas.compat as compat
File "/Users/benjamin/PycharmProjects/pandas/venv/pandas.py", line 1, in <module>
from pandas_datareader import data
ImportError: cannot import name data
sophros
  • 8,714
  • 5
  • 30
  • 57
Cachario
  • 41
  • 1
  • 1
  • 6
  • 2
    Rename your file to something other than “pandas.py” (or any other package names). – abccd Jan 25 '19 at 03:11
  • What have you tried? A quick Google search for this error resulted in a few other questions which were solved by updating or reinstalling. Also as @abccd stated naming your file `pandas.py` is definitely playing with fire. – CodeSpent Jan 25 '19 at 03:15
  • Ok, thanks. I changed the file's name, and the program is now resulting in an error message that says that Python is not installed as a framework for my computer. However, it is installed. (Sorry if I am a noob, as I am new to programming) – Cachario Jan 25 '19 at 03:23
  • In fact, if I delete the matplotlib line, all error messages go away. Any idea what this is about? – Cachario Jan 25 '19 at 03:25

2 Answers2

2

Your pandas version should be >= 0.19.0 to import data from pandas_datareader.

Pandas Datareader

Ayush Bansal
  • 417
  • 4
  • 11
0

Check this question for more clues:

import pandas_datareader gives ImportError: cannot import name 'is_list_like'

use 'pip freeze' to get list of modules with version number and check for any inconsistency

Vishwa
  • 55
  • 1
  • 11