Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module 'scipy.special' has no 'expit' member in Python / SciPy

I try to use expit(x) from SciPy. But I get this error message:

Module 'scipy.special' has no 'expit' member

This is my code:

import numpy
import scipy.special

[...]

def Activation(self, ActivationInput):
    self.ActivationOutput = scipy.special.expit(ActivationInput)
    return self.ActivationOutput

scipy is red underlined in VScode when I try to us it in the function Activation

The solution via Error importing scipy.special.expit was not satisfying and doesn't work.

I use Python 3.7, NumPy 1.14.5 and SciPy 1.1.0.

Other functions work, but all Ufuncs from scipy.special get this error message.

like image 792
Philipp Gensel Avatar asked Sep 15 '25 17:09

Philipp Gensel


1 Answers

All of the ufuncs in scipy.special are written in C and so pylint cannot find the proper definition. You can tell pylint to ignore the module by adding the option --ignored-modules=scipy.special to pylint.

For VSCode:

Adding --ignored-modules=scipy.special via the options GUI or directly to the settings.JSON file is possible, but it turns off the default options that VSCode uses with pylint.

To solve this issue, you can add both the original default options as well as the --ignored-modules flag to the settings.json file.

  • Type [CTRL]+[Shift]+p to open the command search
  • Search for open settings (JSON), which will open you settings file.
  • in settings.JSON add the key / value pairs so you file has the following
{
    // any other options for VSCode

    "python.linting.pylintArgs": [
        "--disable=all",
        "--enable=F,E,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned",
        "--enable=unused-variable,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode",
        "--ignored-modules=scipy.special"
        ],
}

The first 3 lines are the default options used by VSCode for pylint. The 4th line tells pylint to ignore the scipy.special module, which will turn off the error.

like image 164
James Avatar answered Sep 17 '25 07:09

James