Reputation: 11
I am new to python and I am trying to learn how to use it for statistics. I have been trying to use the
from statsmodels.stats.weightstats import ztest
But I get an error when I try to use this command. Here is what it displayed:
Python 2.7.17 (default, Nov 7 2019, 10:07:09)
[GCC 7.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from statsmodels.stats.weightstats import ztest
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jico/.local/lib/python2.7/site-packages/statsmodels/stats/__init__.py", line 1, in <module>
from statsmodels.tools._testing import PytestTester
File "/home/jico/.local/lib/python2.7/site-packages/statsmodels/tools/__init__.py", line 1, in <module>
from .tools import add_constant, categorical
File "/home/jico/.local/lib/python2.7/site-packages/statsmodels/tools/tools.py", line 8, in <module>
from statsmodels.compat.python import lzip, lmap
File "/home/jico/.local/lib/python2.7/site-packages/statsmodels/compat/__init__.py", line 1, in <module>
from statsmodels.tools._testing import PytestTester
File "/home/jico/.local/lib/python2.7/site-packages/statsmodels/tools/_testing.py", line 11, in <module>
from statsmodels.compat.pandas import assert_equal
File "/home/jico/.local/lib/python2.7/site-packages/statsmodels/compat/pandas.py", line 4, in <module>
import numpy as np
File "/home/jico/.local/lib/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__'
>>>
Any help that I can get would be appreciated. I am using python 2.7.17
Upvotes: 1
Views: 2213
Reputation: 21
I'm also working on python 2.7 facing exactly the same problem. Here's how I solved it:
First thing first, it says in error message
NP_LT_114 = LooseVersion(np.version) < LooseVersion('1.14') Thus make sure you have numpy version > 1.14
Secondly, I downgraded statsmodels from 0.11.0 to 0.10.0.
Hope it works for you too.
(numpy==1.16.5, statsmodels==0.10.0, python=2.7)
Upvotes: 2
Reputation: 10304
Just had this issue after conda chose to update numpy from 1.13.3 to 1.14.3. Reverting numpy via procedure in http://blog.rtwilson.com/conda-revisions-letting-you-rollback-to-a-previous-version-of-your-environment/ sufficed to recover functionality, followed by pinning the version in the environment.
also wondering what does shows:
import numpy; print(numpy.__file__)
Upvotes: 0