Scipy function not recognized (expit) - python-3.x

I wanted to use the expit-function from scipy in VSCode. I imported scipy.special, but everytime I want to use expit I get the following error:
"[pylint] E1101:Module 'scipy.special' has no 'expit' member"
Other scipy.special functions like scipy.special.airy work, however.
I'm using python 3.6.5 and scipy 1.1.0. Reinstalling scipy did not help.
Any help would be greatly appreciated.

Edit:
I just found this answer, recommending to whitelist numpy for linting, the same should work for scipy.
I am having a similar issue with the function scipy.special.j1 right now.
Pylint complains saying
Module 'scipy.special' has no 'j1' member; maybe 'jv'?
The weird thing is that even though pylint apparently can't find the function, the following code works:
>>> from scipy.special import j1
>>> print(j1(2))
0.5767248077568734
I think this might be the exact same problem you have. Did you solve it yet? I'd love to get a solution or workaround for this.

Related

how to fix "Module 'cv2' has no ---- member pylint(no-member?

I am trying to start a project to learn how to use opencv and the first problem I encountered is this : "Module 'cv2' has no ---- member pylint(no-member) as posted in the picture.
I have found some information here in Stack Overflow but I'm afraid, I might not be proficient enough to understand what is going on. Could someone point me in the right direction to solve my problem?
Thanks!
One possible reason is that you might have a file named cv2.py somewhere on your machine other than the original cv2 module and now python is importing that file rather than the cv2 module.
Or perhaps you could've downloaded a wrong cv2 module, other than that i don't see anything that could've gone wrong as you don't have a complex code. Try reinstalling the module and/or removing a file named cv2.py (if you've accidentaly created one).
You can check the module by importing the module in the terminal and check for dir, on python console type import cv2 and then dir(cv2), now you should see all the classes contained in the cv2 module.
If the program runs correctly then I guess you are facing linting issue which is answer in this [https://stackoverflow.com/questions/26657265/hide-some-maybe-no-member-pylint-errors] question.
Solution is to turn off no-member linting error using below command
pylint disable=maybe-no-member
OR
pylint --disable=E1101

SKLearn 0.20.2 - Import error with RandomizedPCA?

I'm trying to do the Udacity mini project and I've got the latest version of the SKLearn library installed (20.2).
When I run:
from sklearn.decomposition import RandomizedPCA
I get the error:
ImportError: cannot import name 'RandomizedPCA' from 'sklearn.decomposition' (/Users/kintesh/Documents/udacity_ml/python3/venv/lib/python3.7/site-packages/sklearn/decomposition/__init__.py)
I actually even upgraded the version using:
pip3 install -U scikit-learn
Which upgraded from 0.20.0 to 0.20.2, which also uninstalled and reinstalled... so I'm not sure why it can't initialise sklearn.decomposition.
Are there any solutions here that might not result in completely uninstalling python3 from my machine?! Would ideally like to avoid that.
Any help would be thoroughly appreciated!
Edit:
I'm doing some digging and trying to fix this, and it appears as though the __init__.py file in the decomposition library on the SKLearn GitHub doesn't reference RandomizedPCA... has it been removed or something?
Link to the GitHub page
As it turns out, RandomizePCA() was depreciated in an older version of SKLearn and is simply a parameter in PCA().
You can fix this by changing the import statement to:
from sklearn.decomposition import PCA as RandomizedPCA
... and then your classifier looks like this:
pca = RandomizedPCA(n_components=n_components, svd_solver='randomized', whiten=True).fit(X_train)
However, if you're here because you're doing the Udacity Machine Learning course on Eigenfaces.py, you'll notice that the PIL library is also deprecated.
Unfortunately I don't have a solution for that one, but here's the GitHub issue page, and here's a kind hearted soul that used a Jupyter Notebook to solve their mini-project back when these repositories worked.
I hope this helps, and gives enough information for the next person to get into Machine Learning. If I get some time I might take a crack at recoding eigenfaces.py for SKLearn 0.20.2, but for now I'm just going to crack on with the rest of this course.
In addition to what #Aaraeus said, the PIL library has been forked to Pillow.
You can fix the PIL import error using
pip3 install pillow

Rodeo giving error on Excel import working in Spyder

Full disclosure: I am a total beginner when it comes to Python in particular and programming in general. So please bear with me.
Today I tried for the first time to play around some datasets on my own, outside of the sandboxed environment of online courses.
I downloaded both Anaconda and Rodeo (which somehow I feel more akin to than, say, Spyder or Jupyter).
Wrote down this code. It works in Spyder.
import numpy as np
import pandas as pd
myexcel="C:/Users/myname/folder/subfolder/file.xlsx"
xl=pd.ExcelFile(myexcel)
mydf=xl.parse(0)
print(mydf.head())
However, if I try to run the same code in Rodeo I get the following error message. Here, I am showing just a part.
----> 4 xl=pd.ExcelFile(myexcel)
ImportError: No module named 'xlrd'
I am getting that in Rodeo the script fail because it is missing the xlrd package, which admittedly after checking with help("modules") is not there. But I don't fully get the problem: if xlrd was quintessential to the correct execution of this code, then why doesn't it fail in Spyder?

mkl_blas_dgemm_alloc not found in mkl_intel_thread

I developed a a tool in python 3.5 some time ago which currently only uses differential evolution from scipy to do its task. For some reasons I had to change settings on my machine and switch to use python in a virtual environment.
My specs now:
win 10 64 bit
used pip 9.0.1
numpy 1.12.1+mkl
scipy 0.19.0
python 3.6.1
I have a different env using python 2.7 flying around somewhere else.
Now my problem....everytime the differential evolution function gets its first set of data it crashes after returning the differential_evolution step value.
The differential_evolution call can be found under ./libraries/methods/differential_evoluation.py line 76
The pop-up Error is "Entry point 'mkl_blas_dgemm_alloc wasn't found in 'mkl_intel_thread.dll'." And the printed error is "Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll." Please notice that my system language is german therfore the pop-up message was translated by me.
I don't know whether this is relevant but my directory structure is:
>some_place/location1/goal.py
>some_place/location2/env/
I didn't work with virtualenv before and in addition to this i used python 3.5. I'd appreciate any help or instructions on how to add more information to this case to help clarify my problem.
Yours sincerely
OK I'm back with more information. Maybe someone else will stumble uppon it. To be clear: I do not know the fix or reason. I just tried a bunch of stuff.
Using
python 3.5.3,numpy 1.11.1+mkl and scipy-0.18.0 or scipy-0.19.0
made the error disappear. I couldn't try numpy 1.11.1 or 1.11.2 for python 3.6 because this kind soul sadly doesn't offer those versions anymore. I found the 1.11.1 version for python 3.5 somewhere on my disk.
From my testing i can tell that it breaks once i use numpy 1.11.3 or higher. 1.11.1 works fine. Therefore I assume that some changes happened either in numpy between 1.11.1 and 1.11.3 which break it OR in how this kind soul creates/builds his wheels. So I'm going to use python 3.5 for now as i do not have numpy 1.11.1+mkl for python 3.6.
Yours sincerely

PyQt and PyQtGraph library. qtgui.QGraphicsObject vs pyqtgraph.GraphicsObject

I'm not sure I understand how these work (I'm not even sure if I should talk about these or this). I was reading pyqtgraph examples and found a call to a "GraphicsObject". Looked it up in pyqtgraph's documentation and it seems like they have their own QGraphicsObject class. Is that correct?
I can't manage to import the correct GraphicsObject (amongst others, like GraphicsItem and such; just using that class as an attempt to explain myself better). I've reinstalled the library so it has nothing to do with it, so... what I'm missing? I apologize in advance if the question is silly.
Example:
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
g = pg.GraphItem()
Error displayed about GraphItem in PyCharm:
Cannot find reference 'GraphItem' in 'init.py'
The inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.
*I found what was causing me the trouble. It looks like scipy didn't install correctly although it didn't give me back an error, so I just had to install it in a different way.

Resources