[GIS] Semi-Automatic Classification Plugin Scipy Dependency Error

qgisqgis-2.18qgis-plugins

I've been using QGIS with the Semi-Automatic Classification plugin (SCP) at work, and am attempting to install and use it at home. Unfortunately, I am encountering an error which causes QGIS to crash when installing, disabling, or uninstalling SCP.

Upon opening QGIS 2.18.6, I get the following messages:

Semi-Automatic Classification Plugin: Please, restart QGIS for executing the Semi-Automatic Classification Plugin. Possible missing dependecies: SciPy

Semi-Automatic Classification Plugin: Please, restart QGIS for executing the Semi-Automatic Classification Plugin

From investigating the plugin's source, it looks like it is trying the following import before throwing the SciPy dependency exception:

import scipy.stats.distributions as statdistr

I tried the same import from the OSGeo4W Shell, and get the following traceback:

Taceback (most recen call last):
  File "<stdin>", line 1, in <module>
  File "C:\OSGEO4~1\apps\Python27\lib\site-packages\scipy\stats\__init__.py", line 334,
    in <module> from .stats import *
  File "C:\OSGEO4~1\apps\Python27\lib\site-packages\scipy\stats\stats.py", line 181,
    in <module> import scipy.special as special
  File "C:\OSGEO4~1\apps\Python27\lib\site-packages\scipy\special\__init__.py", line 546,
    in <module> from ._ufuncs import *

Additionally, doing a pip list does not display scipy but does display numpy and matplotlib, the other two dependencies for the plugin.

I've attempted to reinstall QGIS and supporting apps / libraries using the advanced and express installers, but run into the same problem each time I try to install SCP. The error also causes QGIS to crash and write a minidump on close. I'm also using Windows 10.


I am able to import scipy from the OSGeo4W Shell, but any module imports do not work, i.e. import scipy.stats or import scipy.linalg

How can I resolve this specific Scipy dependency issue within QGIS?

Best Answer

Was able to resolve the issue by forgoing the installation of Scipy through the OSGeo4W advanced installer, and instead installing it directly via Pip (installed via OSGeo4W) and a Scipy .whl gotten from:

http://www.lfd.uci.edu/~gohlke/pythonlibs/

I grabbed:

numpy‑1.12.1+mkl‑cp27‑cp27m‑win_amd64.whl and scipy‑0.19.0‑cp27‑cp27m‑win_amd64.whl

Then used the OSGeo4W Shell to install directly:

pip install "C:\path\to\numpy‑1.12.1+mkl‑cp27‑cp27m‑win_amd64.whl"
pip install "C:\path\to\scipy‑0.19.0‑cp27‑cp27m‑win_amd64.whl"

I wanted to make sure that the Numpy installation was also correct because it is a dependency for Scipy, so that's the reason for installing both.

Related Question