How to install scikit-learn - python

I know how to install external modules using the pip command but for Scikit-learn I need to install NumPy and Matplotlib as well.
How can I install these modules using the pip command?

Old post, but right answer is,
'sudo pip install -U numpy matplotlib --upgrade' for python2 or 'sudo pip3 install -U numpy matplotlib --upgrade' for python3

Using Python 3.4, I run the following from the command line:
c:\python34\python.exe -m pip install package_name
So you would substitute "numpy" and "matplotlib" for 'package_name'

Related

pip not working while trying to install torch

I'm trying to install torch for ml-agents and when I run the command
pip install torch~=1.7.1 -f https://download.pytorch.org/whl/torch_stable.html
and it answers:
No Python at 'C:\Program Files (x86)\Python38-32\python.exe'
review/reinstall your python installation. The issue is related to Python and Pip, not that library.
First try to fix:
python --version
then
pip --version

You are using pip version 8.1.1, however version 21.2.3 is available. You should consider upgrading via the 'pip install --upgrade pip' command

I am trying to get started with python on VS Code but I keep getting this error when I want to install the matplotlib library.
Consider using the --user option or check the permissions.
pip install -U --upgrade pip
I tried a lot of different ones but the one below worked for me
pip3 install --upgrade pip --user
Three things to do:
Run this in your bash terminal
python3 pip install --upgrade pip
Configure your VS Code environment for python 3.x
Run your file using python3 [filename.py]
If the above suggestion fails, you should try:
pip install --upgrade pip
I added the folder than tried pip install --upgrade pip and it worked. You may have to show your hidden folders to follow the path.
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases. To fix this problem, I'm trying to install it using this command:
python -m pip install --upgrade pip setuptools virtualenv)

Install Gensim in python3

I have two versions of python: python2, python3.
When I install gensim it goes to python2
I install it with the following comand
sudo pip3 install --upgrade gensim
how can I install it in python3?
You can install it in python3 with the following command:
sudo python3 -m pip install --upgrade gensim
I suggest using a virtualenv with only python3 in it. You can create it using
virtualenv -p /usr/bin/python3 myenv
then activate it using source command.
source myenv/bin/activate
now you can install using pip install gensim that will install it to the python3 specific to that virtual environment.

how to upgrade matplotlib version for python 2.7

How can I upgrade the version of matplotlib to 1.10 for python 2.7
Have you tried just installing it again via pip? Example pip command taken from here:
python -mpip install -U matplotlib
Do you use a virtual environment? If you do - you will have to activate it first. For this go to the console and type
For windows:
activate vitual-environment-name
For ubuntu:
source activate virtual-environment-name
After that (and if you don't have a virtual environment) just type:
pip install -U matplotlib
If that doesn't work try:
python -m pip install -U matplotlib
But in your case the version of six should be >= 1.10.
To do that use pip again and in your console type
pip install -U six
If that doesn't work try:
python -m pip install -U six
pip install -U matplotlib
it is easy to update modules

Installing pip to import modules

I am attempting to install matplotlib and scipy to python, and using pip to do so. However when I attempted to install scipy with pip install scipy --myuser I received the message:
invalid requirement '--myuser'
Previously I had installed numpy using pip with
python get-pip.py —myuser
and
pip install numpy —myuser
This worked fine, so I am unsure what the problem is here.
This is frustrating as I would like to use python from the terminal rather than from my Windows desktop.
If you want to install to user try the below mentioned command:
pip install --user scipy
Here is the help from pip command:
pip install --help
--user Install to the Python user install directory for
your platform. Typically ~/.local/, or
%APPDATA%\Python on Windows. (See the Python
documentation for site.USER_BASE for full
details.)
You should be able to install it without the use of the --myuser argument.
sudo python3 -m pip install scipy
sudo python3 -m pip install matplotlib
or all in one
sudo python3 -m pip install scipy matplotlib
Try this:
sudo python3 -m pip install scipy matplotlib

Categories