0

I just start to use Rodeo with Python 3.6.2. But there is an error when importing statsmodels under Windows 10. Here is the script:

import pandas as pd
import statsmodels.api as sm
import pylab as pl
import numpy as np

When highlight import statsmodels.api as sm and click Run line, there is an error:

>>> import statsmodels.api as sm
ImportError: No module named 'statsmodels'
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-3-6030a6549dc0> in <module>()
----> 1 import statsmodels.api as sm
ImportError: No module named 'statsmodels'

Then I downloaded the statsmodels from Github and installed it. Here is the output of pip list:

C:\Users\Documents\statsmodels-master\statsmodels-master>pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
Cython (0.26)
numpy (1.13.1)
pandas (0.20.3)
patsy (0.4.1)
pip (9.0.1)
python-dateutil (2.6.1)
pytz (2017.2)
scipy (0.19.1)
setuptools (28.8.0)
six (1.10.0)
statsmodels (0.8.0)

The output shows that statsmodels 0.8.0 is installed. But there is still importing error. It seems that the Rodeo has difficulty to see statsmodels.

UPDATE:

Here is the output of print(sys.pth) in Rodeo. There is a path for the statsmodels.

>>> print(sys.path)
['', 'C:\\Python36\\Scripts', 'c:\\python36\\lib\\site-packages\\statsmodels-0.8.0-py3.6-win-amd64.egg', 'C:\\Python36', 'C:\\Python36\\python36.zip', 'C:\\Python36\\DLLs', 'C:\\Python36\\lib', 'C:\\Python36\\lib\\site-packages', 'C:\\Python36\\lib\\site-packages\\patsy-0.4.1-py3.6.egg', 'C:\\Python36\\lib\\site-packages\\pandas-0.20.3-py3.6-win-amd64.egg', 'C:\\Python36\\lib\\site-packages\\six-1.10.0-py3.6.egg', 'C:\\Python36\\lib\\site-packages\\pytz-2017.2-py3.6.egg', 'C:\\Python36\\lib\\site-packages\\python_dateutil-2.6.1-py3.6.egg', 'C:\\Python36\\lib\\site-packages\\IPython\\extensions', 'C:\\Users\\JunC\\.ipython']
user938363
  • 9,990
  • 38
  • 137
  • 303
  • did you do `pip install statsmodels`? – Arpit Solanki Aug 06 '17 at 19:14
  • Installed with `python setup.py install` under `statsmodels` – user938363 Aug 06 '17 at 19:53
  • Tried `pip install statsmodels` and returns all `requirement already satisfied` – user938363 Aug 06 '17 at 20:01
  • 1
    I'm not too familiar with that, but it might be that the package is not installed in a path listed in the `PYTHONPATH`? You can `import sys` then `print(sys.path)` to see where Python can reach packages, then check where the `statsmodels` folder is. – Arthur Spoon Aug 06 '17 at 22:09
  • `Arther Spoon`, I just updated with the output of `sys.path`. Is it possible that the `Rodeo` is using its own python which is not the 3.6.2 I installed? I added the C:\python36 and `statsmodels.egg` to `PYTHONPATH` and those paths are not showing in the output here. – user938363 Aug 07 '17 at 01:35

2 Answers2

1

I had the same issue. I solved it by adding the path to statsmodels to rodes>preferences>environment variables. In my case the path was "C:\ProgramData\Miniconda3\pkgs".

0

You might not have latest version of python2. Either update it, or use python3 instead.

To use python 3, use pip3 instead of pip. So run the following:

pip3 install statsmodels

Community
  • 1
  • 1
Sagar Chand
  • 260
  • 7
  • 18