Problem installing statsmodels

1,981 views
Skip to first unread message

alber...@gmail.com

unread,
May 8, 2014, 1:32:42 AM5/8/14
to pystat...@googlegroups.com
Hello. I need to do multiple regression in Python and it seems statsmodels is the package I should be using. I am using the Canopy version 1.1.1 (64 bit) distribution of Python 2.7, on a Windows 7 laptop. I downloaded the windows installer statsmodels-0.5.0.win-amd64-py2.7.exe and it ran OK, it detected Python 2.7 and gave no errors. If I type 'import statsmodels' in Python, I get no error messages but when I try to use routines like regression and OLS it tells me that 'module' has no attribute 'OLS' (or whatever). If I type 'import statsmodels.api, as the documentation examples suggest, then I get the following error messages. The problem seems to be that there is no module named patsy. Does statsmodels require some other package be installed in order to run? Any help would be greatly appreciated!

 import statsmodels.api
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-32-b81506c9f24a> in <module>()
----> 1 import statsmodels.api

C:\Users\Albert & Julia\AppData\Local\Enthought\Canopy\User\lib\site-packages\statsmodels\api.py in <module>()
      1 import iolib, datasets, tools
      2 from tools.tools import add_constant, categorical
----> 3 import regression
      4 from .regression.linear_model import OLS, GLS, WLS, GLSAR
      5 from .regression.quantile_regression import QuantReg

C:\Users\Albert & Julia\AppData\Local\Enthought\Canopy\User\lib\site-packages\statsmodels\regression\__init__.py in <module>()
----> 1 from linear_model import yule_walker
      2
      3 from statsmodels import NoseWrapper as Tester
      4 test = Tester().test

C:\Users\Albert & Julia\AppData\Local\Enthought\Canopy\User\lib\site-packages\statsmodels\regression\linear_model.py in <module>()
     39 from statsmodels.tools.decorators import (resettable_cache,
     40         cache_readonly, cache_writable)
---> 41 import statsmodels.base.model as base
     42 import statsmodels.base.wrapper as wrap
     43 from statsmodels.emplike.elregress import _ELRegOpts

C:\Users\Albert & Julia\AppData\Local\Enthought\Canopy\User\lib\site-packages\statsmodels\base\model.py in <module>()
      8 import statsmodels.base.wrapper as wrap
      9 from statsmodels.tools.numdiff import approx_fprime
---> 10 from statsmodels.formula import handle_formula_data
     11
     12

C:\Users\Albert & Julia\AppData\Local\Enthought\Canopy\User\lib\site-packages\statsmodels\formula\__init__.py in <module>()
      2 test = Tester().test
      3
----> 4 from formulatools import handle_formula_data

C:\Users\Albert & Julia\AppData\Local\Enthought\Canopy\User\lib\site-packages\statsmodels\formula\formulatools.py in <module>()
      1 import statsmodels.tools.data as data_util
----> 2 from patsy import dmatrices
      3
      4 # if users want to pass in a different formula framework, they can
      5 # add their handler here. how to do it interactively?

ImportError: No module named patsy

Skipper Seabold

unread,
May 8, 2014, 1:52:30 AM5/8/14
to pystat...@googlegroups.com
On Thu, May 8, 2014 at 1:32 AM, <alber...@gmail.com> wrote:
Hello. I need to do multiple regression in Python and it seems statsmodels is the package I should be using. I am using the Canopy version 1.1.1 (64 bit) distribution of Python 2.7, on a Windows 7 laptop. I downloaded the windows installer statsmodels-0.5.0.win-amd64-py2.7.exe and it ran OK, it detected Python 2.7 and gave no errors. If I type 'import statsmodels' in Python, I get no error messages but when I try to use routines like regression and OLS it tells me that 'module' has no attribute 'OLS' (or whatever). If I type 'import statsmodels.api, as the documentation examples suggest, then I get the following error messages. The problem seems to be that there is no module named patsy. Does statsmodels require some other package be installed in order to run? Any help would be greatly appreciated!

Yes, you need to install patsy.

    pip install patsy

It's a dependency.

Skipper

Albert Haig

unread,
May 8, 2014, 2:31:50 AM5/8/14
to pystat...@googlegroups.com
OK, thanks for that! I have installed patsy and it works fine now.
Reply all
Reply to author
Forward
0 new messages