everestial
everestial

Reputation: 7255

ImportError on scipy.stats

I am trying to use a python program, which requires scipy dependency. The scipy dependency is installed, but I need to call scipy.stats and then binom which is within scipy.

I tried the method in these answers:

Import scipy.stats error

No module named scipy.stats - Why despite scipy being installed

>>> import scipy
>>> import scipy.stats
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named stats
>>> from scipy import stats
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name stats
>>> from scipy.stats import binom
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named stats

I am not a sudo user and cannot rename a file, but the filename shouldn’t be the problem as it is used in a frequently used server.

Any suggestions ?

Upvotes: 5

Views: 26078

Answers (1)

Jonathan R
Jonathan R

Reputation: 3948

In your Python-CLI try the following:

>>> import scipy
>>> scipy.__version__
'1.0.0'
>>> scipy.__file__
'/usr/local/lib/python3.6/site-packages/scipy/__init__.py'

Look if your output looks anything similar to this one. If scipy.__file__ points to a private directory of yours, then you have to resolve that namespace problem by renaming your own package. In case it looks similar, then in another terminal move into that directory:

cd /usr/local/lib/python3.6/site-packages/scipy/
ls

Look for a folder called stats/, if it is missing then your scipy is not installed correctly and you should reinstall it.

Upvotes: 3

Related Questions