Skip to content

Unable to import statsmodels #3527

Closed
Closed

Description

@rishabmarkand

I get the following error when I attempt to import statsmodels. (using python version 3.5.2)

ValueError: statsmodels.tsa.statespace._kalman_filter.sKalmanFilter has the wrong size, try recompiling. Expected 5168, got 5792

I have tried recompiling as well but to no avail. I'm quite new to this, so I might be overlooking a simple fix to the problem.

Activity

  1. rishabmarkand commented on Mar 1, 2017

    @rishabmarkand
    Author

    When I use python 2.7.12 I get

    ImportError: cannot import name _representation
  2. josef-pkt commented on Mar 1, 2017

    @josef-pkt
    Member

    Make sure that you have compiled it for the python/numpy/scipy version that you actually use or install statsmodels with.

    This sounds a lot like http://stackoverflow.com/questions/17709641/valueerror-numpy-dtype-has-the-wrong-size-try-recompiling/18369312#18369312
    when versions are not compiled with the matching numpy or other dependencies.

  3. josef-pkt commented on Mar 1, 2017

    @josef-pkt
    Member

    If you are installing from github checkout or building on top of an existing statsmodels version, then you might have to clean cython and binary files from the relevant directories.

    aside
    when I run the "wrong" python version I get the numpy.dtype has the wrong size error

    >>> import statsmodels.api as sm
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    <...>
        from . import _statespace
      File "__init__.pxd", line 155, in init statsmodels.tsa.statespace._statespace
    (statsmodels/tsa/statespace/_statespace.c:94371)
    ValueError: numpy.dtype has the wrong size, try recompiling. Expected 88, got 96
    
  4. ChadFulton commented on Mar 2, 2017

    @ChadFulton
    Member
  5. josef-pkt commented on Mar 2, 2017

    @josef-pkt
    Member

    @ChadFulton
    Doesn't the re-compile hash and check each file separately?
    Right now we are not on a scale where rebuilding the entire statespace binaries would be a heavy burden. So rebuilding all files sounds fine to me, and is more user friendly. (Because I have other untracked modules in the checkout tree that I don't want to delete, I have to figure out which files to manually delete in this case.)

  6. rishabmarkand commented on Mar 2, 2017

    @rishabmarkand
    Author

    Cleaning and building again works

    python setup.py clean -a
    python setup.py build_ext --inplace

    Able to import now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions