John
John

Reputation: 161

How to fix error "'module' has no attribute '__version__'" with statsmodels package?

I am trying to use the "statsmodels" package. When I try to import the package using this command:

import statsmodels

it works perfectly but when I tried to run the following comand in Python 2:

from statsmodels.distributions.empirical_distribution import ECDF

I will get the following error:

Traceback (most recent call last): 
  File "circleseq/circleseq.py", line 16, in <module>
    import findCleavageSites
  File "/mnt/data/users/S.Sie/circleseq/circleseq-master/circleseq/findCleavageSites.py", line 8, in <module>
    from statsmodels.distributions.empirical_distribution import ECDF
  File "/usr/lib64/python2.7/site-packages/statsmodels/distributions/__init__.py", line 1, in <module>
    from statsmodels.tools._testing import PytestTester
  File "/usr/lib64/python2.7/site-packages/statsmodels/tools/__init__.py", line 1, in <module>
    from .tools import add_constant, categorical
  File "/usr/lib64/python2.7/site-packages/statsmodels/tools/tools.py", line 8, in <module>
    from statsmodels.compat.python import lzip, lmap
  File "/usr/lib64/python2.7/site-packages/statsmodels/compat/__init__.py", line 1, in <module>
    from statsmodels.tools._testing import PytestTester
  File "/usr/lib64/python2.7/site-packages/statsmodels/tools/_testing.py", line 11, in <module>
    from statsmodels.compat.pandas import assert_equal
  File "/usr/lib64/python2.7/site-packages/statsmodels/compat/pandas.py", line 4, in <module>
    import numpy as np
  File "/usr/lib64/python2.7/site-packages/statsmodels/compat/numpy.py", line 46, in <module>
    NP_LT_114 = LooseVersion(np.__version__) < LooseVersion('1.14')
AttributeError: 'module' object has no attribute '__version__'

I have to work with Python 2 since the tool I am using is in Python 2. How I can fix the issue?

Upvotes: 0

Views: 3463

Answers (1)

dee cue
dee cue

Reputation: 1053

Since you only work on Python 2, is it possible to rollback statsmodels where it was compatible to Python 2? You may lost some features, but you can check yourself if the older version is enough to fill in your requirements.

To rollback to an older version of a package, you can add the -I flag to your pip install.

pip install -I <package>==<version>

Upvotes: 1

Related Questions