As I was doing my Machine Learning Specialization at Coursera, in one of the programming assignments, I faced an issue while trying to use the multivariate_normal component of scipy.
I had to import
from scipy.stats import multivariate_normalwhich was giving the below error
ImportError: cannot import name multivariate_normal
As mentioned in many online forums, I found out that the issue was, my scipy version is 0.13.3 and the multivariate_normal is supported only in 0.14 and above. Many people suggested to run the command
sudo pip install scipy --upgrade
to upgrade the scipy, but for that was failing with the below error
'ascii' codec can't decode byte 0xe2 in position 66: ordinal not in range(128)Below are the steps I followed to fix it
Step 1) First need to make sure all scipy dependencies are installed properly
sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-noseStep 2) Make sure the numpy, which scipy is dependent on is up-to-date
sudo pip install numpy --upgradeStep 3) Make sure all the build dependencies of scipy is available
sudo apt-get build-dep python-scipyStep 4) Rerun the upgrade
sudo pip install scipy --upgradeNow when I try to import multivariate_normal it works fine
$ python Python 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from scipy.stats import multivariate_normal >>>