Re: [pystatsmodels] ImportError: No module named statsmodels.api

2,416 views
Skip to first unread message

Skipper Seabold

unread,
Aug 4, 2012, 6:05:44 PM8/4/12
to pystat...@googlegroups.com
On Sat, Aug 4, 2012 at 6:01 PM, Surfcast23 <surfc...@gmail.com> wrote:
>
>
> Hi All,
> I downloaded the StatsModels source from
> http://pypi.python.org/pypi/statsmodels#downloads and untarred to
>
> /usr/local/lib/python2.7/dist-packages

You don't want to untar the source here. You'll want to use some other
directory.

>
> per the documentation at
> http://statsmodels.sourceforge.net/devel/install.html did this
>
> sudo python setup.py install
>
> It installed, but when I try to import
>
> import statsmodels.api as sm
>
> I get the following error
>
> Traceback (most recent call last):
> File "/home/Astrophysics/Histogram_Fast.py", line 6, in <module>
> import statsmodels.api as sm
> ImportError: No module named statsmodels.api
>
> I read a few post that have had a similar problem and checked that
> setuptools was installed and it was also in
>
> /usr/local/lib/python2.7/dist-packages
>
> Running
> numpy 1.6, scipy 0.9.0, pandas 0.8.2
>
> I'm kinda at a loss on this and would appriceate any help Thank you!
>

Try untarring in a different directory. Then install as you were. Then
from some other directory (not where you untarred statsmodels) could
you try to import again?

>
>
>

Khary Richardson

unread,
Aug 4, 2012, 7:02:02 PM8/4/12
to pystat...@googlegroups.com
Hi,

  I untarred in my home directory ran the install received this message

Installed /usr/local/lib/python2.7/dist-packages/statsmodels-0.4.3-py2.7-linux-i686.egg
Processing dependencies for statsmodels==0.4.3
Finished processing dependencies for statsmodels==0.4.3

But when I tried to run the script I got

Traceback (most recent call last):
  File "/home/khary/Astrophysics/Histogram_Fast.py", line 6, in <module>

    import statsmodels.api as sm
ImportError: No module named statsmodels.api

I looked and it is in the folder is in the directory.

Khary
--
StriperCoast SurfCasters Club

Skipper Seabold

unread,
Aug 4, 2012, 7:04:53 PM8/4/12
to pystat...@googlegroups.com
On Sat, Aug 4, 2012 at 7:02 PM, Khary Richardson <surfc...@gmail.com> wrote:
> Hi,
>
> I untarred in my home directory ran the install received this message
>
> Installed
> /usr/local/lib/python2.7/dist-packages/statsmodels-0.4.3-py2.7-linux-i686.egg
> Processing dependencies for statsmodels==0.4.3
> Finished processing dependencies for statsmodels==0.4.3
>
> But when I tried to run the script I got
>
> Traceback (most recent call last):
> File "/home/khary/Astrophysics/Histogram_Fast.py", line 6, in <module>
>
> import statsmodels.api as sm
> ImportError: No module named statsmodels.api
>
> I looked and it is in the folder is in the directory.
>

What OS are you on? Are you sure you installed to the same Python your
script is using?

Khary Richardson

unread,
Aug 4, 2012, 7:19:41 PM8/4/12
to pystat...@googlegroups.com
I am using Ubuntu 12. The script is using python 2.7.3 and statsmodels was installed in 
/usr/local/lib/python2.7/dist-pagkages

Khary
--
StriperCoast SurfCasters Club

Skipper Seabold

unread,
Aug 4, 2012, 7:37:03 PM8/4/12
to pystat...@googlegroups.com
On Sat, Aug 4, 2012 at 7:19 PM, Khary Richardson <surfc...@gmail.com> wrote:
> I am using Ubuntu 12. The script is using python 2.7.3 and statsmodels was
> installed in
> /usr/local/lib/python2.7/dist-pagkages
>

Odd. Did you remove the untarred directory from dist-packages first?
Make sure you don't have a statsmodels directory anywhere in there,
then could you cd to the source directory and run

sudo python setup.py install &> build.log

And then post the full contents of build.log either here or on a site
such as pastie.org.

Skipper

Khary Richardson

unread,
Aug 4, 2012, 7:47:03 PM8/4/12
to pystat...@googlegroups.com

Ok so there are two statsmodels directories in fist-packages. one that is statsmodels-0.4.3-py2.7   and the other has egg added to the file name. Should I remove the egg one and try to run the script ?

Sent from my EVO

Skipper Seabold

unread,
Aug 4, 2012, 7:49:07 PM8/4/12
to pystat...@googlegroups.com
On Sat, Aug 4, 2012 at 7:47 PM, Khary Richardson <surfc...@gmail.com> wrote:
> Ok so there are two statsmodels directories in fist-packages. one that is
> statsmodels-0.4.3-py2.7 and the other has egg added to the file name.
> Should I remove the egg one and try to run the script ?
>

I would go ahead and remove them both.

Khary Richardson

unread,
Aug 4, 2012, 8:07:16 PM8/4/12
to pystat...@googlegroups.com

Will give it a shot and report on the build log

Sent from my EVO

Khary Richardson

unread,
Aug 4, 2012, 8:43:37 PM8/4/12
to pystat...@googlegroups.com
Deleted them both as well as the untarred folder in my home directory. Re untarred and rebuilt and it now works.Thank you ! Do you still want the build log?

Khary
--
StriperCoast SurfCasters Club

Skipper Seabold

unread,
Aug 4, 2012, 8:50:01 PM8/4/12
to pystat...@googlegroups.com
On Sat, Aug 4, 2012 at 8:43 PM, Khary Richardson <surfc...@gmail.com> wrote:
> Deleted them both as well as the untarred folder in my home directory. Re
> untarred and rebuilt and it now works.Thank you ! Do you still want the
> build log?
>

Nope. Let us know if you need anymore help.

Skipper
Reply all
Reply to author
Forward
0 new messages