Installing Scipy.stats on pythonanywhere - python

At pythonanywhere I want to upload the page that works fine on my computer. While installing the scipy.stats module using:
pip install -U scipy.stats
in my virtual environment, I get this response:
Collecting scipy.stats
Could not find a version that satisfies the requirement scipy.stats (from versions: ) No matching distribution found for scipy.stats
checking with pip list, I see that scipy (0.19.0) is installed.
When I replace the import statement in my actual code with
from scipy import stats
and migrate, I get an error where the last few lines are these:
from scipy import stats
File "/home/Equinox/.virtualenvs/homepage/lib/python3.5/site-packages/scipy/__init__.py", line 105, in <module>
from scipy._lib._version import NumpyVersion as _NumpyVersion
ImportError: No module named 'scipy._lib'
I do have numpy also installed. And it would not find a module 'scipy._lib' (and no 'scipy._lib._version' either) if I try to install it. How would I proceed now? How can I install scipy.stats?
Thanks

scipy.stats is already installed if scipy is available (it is part of scipy).
You then just need to import it correctly!
Try:
from scipy import stats

Related

Recieving an error importing scipy.signal

I am trying to use scipy.signal but keep getting an error when I try to import it in my code.
I have:
import scipy,
from scipy import signal
in my code and I have used pip install to install scipy, but I always get the error:
ImportError: DLL load failed: The specified module could not be found. (as seen in image)
I recieve when I try to run my code.
Can you try reinstalling SciPy again? (with the latest version). It worked for me.

Trouble with Cluster Module Spectral Cluster import of Scikit-Learn, install is functioning with other modules

I am trying to do Kmeans with sklearn and I am getting weird error that says:
Traceback (most recent call last):
File "kmean_test.py", line 2, in <module>
from sklearn.cluster import KMeans
File "C:\Python\lib\site-packages\sklearn\cluster\__init__.py", line 6, in <module>
from .spectral import spectral_clustering, SpectralClustering
ModuleNotFoundError: No module named 'sklearn.cluster.spectral'
Working on Windows, I tried importing in Jupyter and just running a simple script from command.
I have tested my install of Scikit-Learn with the following imports and they work fine.
from sklearn import datasets
from sklearn import naive_bayes
First bit of code that i get the traceback error looks like:
import cv2, numpy as np
from sklearn.cluster import KMeans
def visualize_colors(cluster, centroids):
...
I got this import code
from sklearn.cluster import KMeans
from two tutorial sources but perhaps it is the problem? I have made attempts to import otherways but been unsuccessful
Just in case it was the sklearn install and because of reading through other stackoverflow suggestions I have:
I have tried uninstall and reinstall of numpy (with and without mkl), pandas, scikit-learn, and scipy both from regular command and admin command.
I have tried update as well.
I have downloaded the wheels and run install as administrator.
I am new. Please be kind. I am new to Windows development as well, Ugh! So if it has something to do with some complicated Windows system setup and software install etc etc I may not follow. I have spent 2 days trying to solve this one on my own and finally decided to reach out.
Thanks for any help!
UPDATE:
As per suggested below I have confirmed I do have the most recent version of sklearn 0.21.3
import sklearn
print(sklearn.__version__)
0.21.3
For the record here are my versions of the others:
python --version
Python 3.7.3
import numpy
numpy.version.version
'1.17.2'
import scipy
scipy.version.version
'1.3.1'
import pandas as pd
pd.__version__
'0.24.2'
Finally I would like to mention that I have been able to successfully apply Kmeans to my project without sklearn, however, I am trying to access the % and RGB values of the means. I have found two people showing how to do it and BOTH use sklearn. See here end comment by nathancy on why I am trying to install sklearn to do this specific thing: How to find the average colour of an image in Python with OpenCV?
You have installed an older version of sklearn.
from sklearn.cluster import KMeans with work only if you have the latest sklearn version which is 0.21.3
To check the version use:
import sklearn
print(sklearn.__version__)
Finally install sklearn latest version:
pip install -U scikit-learn

cannot import name '_nd_image' - SCIPY

I'm having this problem:
File "C:\IntelPython3\lib\site-packages\scipy\ndimage\filters.py", line 37, in
from . import _nd_image
ImportError: cannot import name '_nd_image'
I was checking in that path and i can't find any module or something called nd_image but i've looked for all the scipy releases and i can't find it too.
Can someone help please? (WINDOWS)
You might be using the older version of scipy with the latest version of python.
You should upgrade scipy to solve the problem by typing below command line.
pip install --upgrade scipy
If you are not using pip in Window, you can use conda or other things.
And actually, you can not find _nd_image.py module. This question might be helpful.

How to import Scipy and Numpy in Python?

I am very new to Python and want to add Numpy and Scipy module. I think my question is very simple for you. I am using Python 3.06a.1 version. I think I already installed something called Anaconda that contains those library. When I type import scipy I get the following message:
import scipy
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
import scipy
ImportError: No module named 'scipy'
also when I want to installed with command line I get the following message which means that I have it already.
localhost:~ user$ pip install scipy
Requirement already satisfied (use --upgrade to upgrade): scipy in ./anaconda/lib/python3.5/site-packages
localhost:~ user$
Please help me to fix this problem
You shouldn't have problem with scipy and numpy if you installed Anaconda. What I'm advising you may sound stupid, but I'm sure it has a good chance to solve your problem.
Relaunch Anaconda, reboot your computer, reinstall Anaconda.
Edit : also watch out to use "scipy" and not "spicy" as I just witnessed in your logs.
if you are using anaconda, try installing scipy using anaconda:
conda install scipy

Problems importing scipy.integrate module

I have a reoccurring issue with importing the integrate module of scipy.
Periodically, I get the Error message "ImportError: cannot import name integrate".
Usually, I use the statement import scipy.integrate to import the module.
Only using import scipy successfully imports scipy but without the integrate module.
The funny thing is that this behavior can change each time I start Python. So sometimes it works fine even when the same script is run.
Anybody has any suggestions?
I had the same problem.
My issue was that python-2.7 would not let me import scipy.integrate, but python-3.x would allow the import.
I'm not a professional, but I had the issue with importing of scipy.integrate package even after successful installing of scipy package via 'pip install scipy'.
The Error was '
No module named 'scipy.special
'.
I randomly solved the issue, maybe my solution will be applicable in your case.
Briefly:
I use Python3 and for installing packages it is better to use 'pip3' command, not 'pip'.
More details:
So initially, I had used 'pip install scipy' and this didn't work.
When I tried to use 'pip3 install scipy', there was a message saying that all the requirement are satisfied, but scipy.integrate still was unavailable with the same Error.
When I tried to uninstall scipy via 'pip uninstall scipy' there was a message that scipy is not installed (but actually, it still was installed).
So I went to 'C:\Users\{username.username}\AppData\Local\Programs\Python\Python310\Lib\site-packages' and deleted the folder named 'scipy'.
Thereafter, I reran the command 'pip3 install scipy' and everything was installed successfully and the following commands worked well in my Jupyter Notebook:
'
import numpy as np
import scipy
import scipy.integrate as integrate
import scipy.special as special
'
The following functions became available: quad, dblquad, tplquad, odeint, ode via the:
from scipy.integrate import quad, dblquad, tplquad
and
from scipy.integrate import odeint, ode

Categories