0

So my installation for statsmodels has been very messy - I've actually had to move the folder into Enthought's site-packages folder myself. But anyway now, when I choose to import statsmodels.api as smapi, I get the following list of error messages:

ImportError                               Traceback (most recent call last)
/home/joshuajoseph/Desktop/ANU PhD 2016 onwards/msagnfracs.py in <module>()
      9 import matplotlib.cm as cm #colour maps for plotting
     10 from operator import truediv #to divide lists
---> 11 import statsmodels.api as smapi
     12 import statsmodels.graphics as smgraphics
     13 

/home/joshuajoseph/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/statsmodels/api.py in <module>()
      3 from . import tools
      4 from .tools.tools import add_constant, categorical
----> 5 from . import regression
      6 from .regression.linear_model import OLS, GLS, WLS, GLSAR
      7 from .regression.quantile_regression import QuantReg

/home/joshuajoseph/Enthought/Canopy_64bit/User/lib/python2.7/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

/home/joshuajoseph/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/statsmodels/regression/linear_model.py in <module>()
     50                                           cache_readonly,
     51                                           cache_writable)
---> 52 import statsmodels.base.model as base
     53 import statsmodels.base.wrapper as wrap
     54 from statsmodels.emplike.elregress import _ELRegOpts

/home/joshuajoseph/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/statsmodels/base/model.py in <module>()
      9 import statsmodels.base.wrapper as wrap
     10 from statsmodels.tools.numdiff import approx_fprime
---> 11 from statsmodels.formula import handle_formula_data
     12 from statsmodels.compat.numpy import np_matrix_rank
     13 from statsmodels.base.optimizer import Optimizer

/home/joshuajoseph/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/statsmodels/formula/__init__.py in <module>()
      2 test = Tester().test
      3 
----> 4 from .formulatools import handle_formula_data

/home/joshuajoseph/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/statsmodels/formula/formulatools.py in <module>()
      1 from statsmodels.compat.python import iterkeys
      2 import statsmodels.tools.data as data_util
----> 3 from patsy import dmatrices, NAAction
      4 import numpy as np
      5 

ImportError: No module named patsy 

So it would appear patsy isn't installed. But when I do pip install patsy, I get the following:

Requirement already satisfied (use --upgrade to upgrade): patsy in ./Enthought/Canopy_64bit/User/lib/python2.7/site-packages/patsy-0.4.1-py2.7.egg Requirement already satisfied (use --upgrade to upgrade): six in ./Enthought/Canopy_64bit/User/lib/python2.7/site-packages (from patsy) Requirement already satisfied (use --upgrade to upgrade): numpy in ./Enthought/Canopy_64bit/User/lib/python2.7/site-packages (from patsy)

and checking in my site-packages folder, I see this:

patsy-0.4.1-py2.7.egg

Which is what the above bit of code points to. But that's it. This alone clearly isn't helping me out with my statsmodels problem, yet I can't do any more to install patsy. If I try to upgrade it (pip install --upgrade patsy), I get this:

Requirement already up-to-date: patsy in ./patsy-0.4.1-py2.7.egg Requirement already up-to-date: six in /home/joshuajoseph/Enthought/Canopy_64bit/User/lib/python2.7/site-packages (from patsy) Requirement already up-to-date: numpy in /home/joshuajoseph/Enthought/Canopy_64bit/User/lib/python2.7/site-packages (from patsy)

Can anyone help me figure out what's going on?

  • It appears you are using a virtualenv. Are you sure the `patsy/` sub-directory (not the egg file) inside `site-packages/` has appropriate permissions/is present. You can also try to remove patsy first and then re-install it. – RedBaron Mar 04 '16 at 04:36
  • Hi @RedBaron, that's just the problem though - there is no `patsy/` subdirectory in the `site-packages/` directory! – Joshua D'Agostino Mar 04 '16 at 04:39
  • 3
    Then `patsy` isn't actually installed (pip only looks at egg file to see if the package is installed). You can run `pip remove patsy` and then `pip install patsy` from your virtualenv to re-install patsy properly. Just to be sure, you can run `pip remove patsy` multiple times (till it complains no `patsy` can be found) and then run the `install` – RedBaron Mar 04 '16 at 05:01

1 Answers1

0

Go to the folder to where you installed your interpreter. In my case my interpreter was conda. So I found it in my AppData folder in C:\Users\%Username% folder.

  • Open the folder containing _conda.exe or whatever interpreter you installed
  • Go to the envs folder, assuming you already setup the environment for your interpreter. Then that folder should be there
  • Follow the sequence myenv\Lib\site-packages inside of it. In this directory this will display all the packages installed in your environment.
  • And if the patsy folder is not there go up the directory of the interpreter again and go to this directory Lib\site-packages. Most likely this is where you'll end up finding the package you installed.
  • Just find the files: patsy and patsy-0.5.1-py3.7.egg-info
  • Copy them and paste them in this directory myenv\Lib\site-packages again.

It worked for me. I hope it will work for you too

Gryu
  • 2,102
  • 2
  • 16
  • 29