Sklearn installation - installation

I have installed sklearn library using
pip install sklearn
but while importing it it shows there is no any library called sklearn that is it gives import error
and afterwars i checked again installing using same command mentioned above but it says requirement already satisfied.
Why it showing like this?
What may be the solution for it? Here is the problem screenshot while importing
It's in CMD
C:\Users\scann>pip install sklearn
Requirement already satisfied: sklearn in c:\users\scann\appdata\local\programs\python\python310\lib\site-packages (0.0.post1)
C:\Users\scann>pip install -U sklearn
Requirement already satisfied: sklearn in c:\users\scann\appdata\local\programs\python\python310\lib\site-packages (0.0.post1)
I tried many methods for installation using github and using -U
But also i Didn't find any correct solution

As of today (2023-01-09), pip install sklearn is in a "brownout" period, and installing this way will eventually be removed.
The preferred installation method is:
pip install scikit-learn
The reason for deprecation is listed as:
sklearn package on PyPI exists to prevent malicious actors from using the sklearn package, since sklearn (the import name) and scikit-learn (the project name) are sometimes used interchangeably. scikit-learn is the actual package name and should be used with pip.
Further reading:
https://github.com/scikit-learn/sklearn-pypi-package
https://github.com/scikit-learn/scikit-learn/issues/24204

Related

MoviePy Not Properly Installed (Linux Mint 20)

I have run pip3 install moviepy simply to get the software installed. However I am unable to use it.
On a second run of pip I get:
Requirement already satisfied: moviepy in /usr/local/lib/python3.8/dist-packages (1.0.3)
but I have no access to the attributes of moviepy. When I run dir(moviepy) I only get:
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', 'version']
Have I done something wrong here, or is this to do with anything else I may have installed?
According to the docs you need to import the package like this:
from moviepy.editor import *
pip install moviepy installs the latest stable version from PyPI, currently it's 1.0.3. __init__.py for the version is mostly empty, it doesn't import anything interesting. That what you see.
You need to import a subpackage and run dir() on it:
import moviepy.video
print(dir(moviepy.video))

Importing gensim

I've installed gensim, however I keep getting an error when I try to import it
from gensim.models import Word2Vec
ImportError: cannot import name 'open'
I'm using the updated version of gensim 3.8.0 and smart_open 2.1.0.
I have reinstalled several times but still can't get it to work.
I also have the same problem, after that I found a solution:
pip install --upgrade gensim
You can install first , then you can import:
import gensim.downloader as gensim_api
import gensim
Works for Mac.

ModuleNotFoundError for 'modin' even though it is installed by poetry

On import modin.pandas as modin_pd line I get ModuleNotFoundError: No module named 'modin'. I am using poetry & JupyterLab. If in the cell I type !poetry add modin, I get ValueError saying Package modin is already present.
So it cannot install modin because it is already installed but it cannot import it either. Any obvious solution that I am missing?
pip freeze command also shows modin to be installed. I also tried to install it via pip install but absolutely nothing let me to import this module in the end.
The problem may be this one KeyError: CPU
It can be solved by using pip install psutil

install "sub package" Jupyter Notebook

I am struggling to install packages, and "sub-packages" in Jupyter Notebook; I suspect I am missing some of the basic concepts around installing packages.
I understand that to install a package within the notebook I use
! pip install --user <package>
What I don't understand is how to install a "sub-package" (feel free to advise what the correct terminology is) such as below.
from nltk.tagger import *
Here is the original script that this comes from:
If i try :
!pip install nltk.tagger
I get the following error information / error
Collecting nltk.tagger
Could not find a version that satisfies the requirement nltk.tagger (from versions: ) No matching distribution found for nltk.tagger
So my first question is. How do I install this nltk.tagger subpackage? Also if tagger is a sub-package of NLTK, how come it isn't installed when I do a pip install NLTK?
Although the error mentions a version, searching online I can't find a reference even to the subpackage "tagger". Any advice or links explaining this would be appreciated.
if you pip inslall nltk, the subpackage nltk.tagger, and other dependencies will be installed too.
This is generally true for all packages.

Installing numpy on mac with pip: "requirements already satisfied" but "No module numpy"

I have python2.7.8 on mac, things I did:
sudo easy_install pip - worked.
pip install numpy:
Requirement already satisfied (use --upgrade to upgrade): numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
I also did "pip upgrade numpy" - no luck. What's wrong?
Your problem is a conflict of different Python versions.
I would recommend installing Python and all the packages, such as numpy, scipy, matplotlib, pandas, etc via Brew
See this tutorial: https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Homebrew-and-Python.md
You can verify which Python you're running with which python or which python3 in Terminal.
This solution is more flexible and cleaner in my opinion than using Conda/Miniconda. However it is also a bit more lengthy to install, as you need to have Xcode, devtools installed to build everything
Could it be that you have multiple versions of python installed? What happens if you run python using the full path like this:
$ /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2
instead of just python2?
In my experience on Mac (and other OS too) it is best to go with Anaconda / Miniconda. This is especially true for packages like NumPy and others from scientific stack.
While Anaconda is a full-blown distribution with about 200 packages, Miniconda is just Python with a few basic libraries. The big advantage is that all packages install as binary. Further, it makes it very simple and stable to install multiple Python versions side by side. For example:
conda create -n py27 python=2.7
creates a new environment with Python 2.7. Activate with:
source activate py27
Now:
conda install numpy
installs NumPy cleanly.
You can do the same for Python 3.5 and switch between environments with source activate.
After jumping from one stackoverflow answer to another I found the solution!
my problems were:
numpy at different location( actually at right, expected-to-be location). It was the IDLE that looks for its own default folder where python2.7 installed.
I checked that my numpy is working like this, run this script to check it is working:
import os
import sys
import pygame
sys.path.insert(0, '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python')
import numpy
pygame.init()
print "( using __version__): " + numpy.__version__
print numpy.version.version
user_paths = os.environ['PYTHONPATH']
print(user_paths)
sys.path insertion adds additional path to IDLE, so it knows where to look for numpy.
Then I check if numpy truly imported - i just print its version. Right now it is 1.8.0rc.
I want to find a way to avoid using this syspath insertion all the time.
So far so good - for now.
I had a similiar problem with numpy. However, it was resolved by choosing the right environment. If you are using VScode, open the command palette (ctrl+shift+p) and type
Python: Select Interpreter.
From there, try choosing the right virtual environment/Interpreter.

Resources