Why would ipython session not be able to import a module but a python shell session would? Both were executed under the same data_science environment?
(data_science) C:\Users\ddonovan>python
Python 3.6.5 | packaged by conda-forge | (default, Apr 6 2018, 16:13:55) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> pd.core.common.is_list_like = pd.api.types.is_list_like
>>> import pandas_datareader.data as web
>>> exit()
(data_science) C:\Users\ddonovan>ipython
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import pandas as pd
In [2]: pd.core.common.is_list_like = pd.api.types.is_list_like
In [3]: import pandas_datareader.data as web
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-3-bc32bb8bec34> in <module>()
----> 1 import pandas_datareader.data as web
ModuleNotFoundError: No module named 'pandas_datareader'
I am guessing that you don't have ipython
installed into the data_science
environment. When you call ipython
from the CMD prompt it is defaulting back to the base Anaconda environment and launching from C:\Program Files\anaconda3\Scripts
(or wherever the base install is located).
You can check several ways:
Using conda. Run conda list -n data_science ipython
from the CMD. If IPython does not appear in the list of installed packaged, you are running from the base environment.
Using where. Run where ipython
. If this does not point to a path in the data_science
environment, then you are running from the base environment.
Using python. Launch ipython
from the CMD, then run
import sys
sys.executable
if the output is not a path to the data_science
environment, you are probably running from the base environment.
To solve your issue, use conda to install IPython:
conda install ipython -n data_science