Skip to content

FAQ: Statsmodels 0.9/Scipy 1.3.0 incompatibility #5759

Closed

Description

@thve

Describe the bug

Hello,

Since release 1.3.0 of Scipy aliases from scipy.misc (comb, factorial, factorial2, factorialk, logsumexp, pade, info, source, who) which have been deprecated since v1.0.0 are removed.

Resulting in incompatibility between statsmodels and scipy.

Code Sample, a copy-pastable example if possible

In a python 3 env

pip install statsmodels
pip install scipy

Then in a python shell

import statsmodels.stats.api as sm
# ImportError: cannot import name 'comb' from 'scipy.misc'

Expected Output

statsmodels is working with scipy 1.2.1 but it will be better than statsmodels stay compatible with last scipy release.

Activity

  1. mfschmidt commented on May 20, 2019

    @mfschmidt

    According to bashtage at #5747 you can install from the master branch and everything works. I tried this as follows:

    pip install --upgrade Cython
    pip install --upgrade git+https://github.com/statsmodels/statsmodels
    

    It seemed to resolve the issue for me, so far.

  2. pinned this issue on May 20, 2019
  3. bashtage commented on May 20, 2019

    @bashtage
    Member

    statsmodels 0.9 is not compatible with SciPy 1.3.0. The current master branch is compatible and the next release will be compatible. The options are to downgrade SciPy, install in a virtual- or conda-env with SciPy 1.2, or to install from master using the code provided above.

  4. changed the title [-]statsmodels x scipy 1.3.0 incompatibility[/-] [+]FAQ: Statsmodels 0.9/Scipy 1.3.0 incompatibility[/+] on May 20, 2019
  5. stonebig commented on May 20, 2019

    @stonebig

    when is the next [pypi] release ? at least a statsmodels-10.0.0dev1 would be nice to have on pypi

  6. ptornich commented on May 22, 2019

    @ptornich

    Is there any predictions for a pypi release?

  7. bashtage commented on May 22, 2019

    @bashtage
    Member
  8. added a commit that references this issue on May 26, 2019
  9. tiffanyhsu001 commented on Jun 5, 2019

    @tiffanyhsu001

    after installing from master:
    pip install --upgrade git+https://github.com/statsmodels/statsmodels

    i get this new (similar) error:
    ImportError: cannot import name 'factorial' from 'statsmodels.compat.scipy'

    i have scipy 1.3.0
    someone help?

  10. bashtage commented on Jun 5, 2019

    @bashtage
    Member

    You need to make sure you have removed any previous version

    Run this command a few times until you get a message that it isn't installed.

    pip uninstall statsmodels -y
    

    This is not a bug in master so something is wrong with the one installed.

  11. tiffanyhsu001 commented on Jun 5, 2019

    @tiffanyhsu001

    @bashtage fixed it thank you!

  12. added a commit that references this issue on Jun 9, 2019
  13. mhooreman commented on Jun 14, 2019

    @mhooreman

    Hello,

    If it can help anybody, here's a shell script workaround in the meanwhile.

    #!/usr/bin/env bash
    
    # Attention: this patches scipy => when statmodels is fixed, you need to
    #            re-install scipy in order to "unpatch" it
    
    initPy=$(pip show scipy | grep 'Location' | awk -F ': ' '{print $2"/scipy/misc/__init__.py"}')
    
    cat <<EOF >>$initPy
    
    # https://github.com/statsmodels/statsmodels/issues/5759 workaround
    from ..special import factorial, logsumexp, comb
    __all__ += ['factorial', 'logsumexp', 'comb']
    EOF 

    Best regards.

  14. KonstantinDoronin commented on Jun 17, 2019

    @KonstantinDoronin

    hi, update till the current moment for PyCharm.
    1.Delete modules Scipi and statmodels (any version)
    2. Install scipi last vestion
    3. Install statmodels module
    and it works!

  15. astrojuanlu commented on Jun 17, 2019

    @astrojuanlu

    If you want to keep stable statsmodels:

    pip install "scipy<1.3"
    

    (don't do this if you installed SciPy with conda)

    If you want to try the upcoming statsmodels version while keeping the latest scipy:

    pip install --pre statsmodels
    
  16. clemenspeters commented on Jun 18, 2019

    @clemenspeters

    Thanks @bashtage

    1. pip install statsmodels==0.10.0rc2 --pre

    2. Restarting the kernel of the jupyter notebook

    fixed it for me.

    You can check your versions with pip list

  17. bashtage commented on Jun 24, 2019

    @bashtage
    Member

    0.10.0 has been released. Only sdist is on PyPI. Wheels should follow in the next day or so.

  18. unpinned this issue on Jun 24, 2019
  19. bhattaraiprabhat commented on Jul 5, 2019

    @bhattaraiprabhat

    Thanks @bashtage,@ clemenspeters:
    Finally, 1. pip install statsmodels==0.10.0rc2 --pre

              2. Restarting the kernel of the jupyter notebook (Must)
    

    Solved the issue!

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions