1

I try to install scikit-learn for Python 3. I do it in the following way:

virtualenv model_env
source  model_env/bin/activate
pip3 install sklearn

As a result I get the following error message:

Downloading/unpacking sklearn
  Cannot fetch index base URL https://pypi.python.org/simple/
  Could not find any downloads that satisfy the requirement sklearn
Cleaning up...
No distributions at all found for sklearn

I had the same problem with pandas package and I have resolved it by using the following command:

sudo apt-get install python3-pandas

Unfortunately, the same approach does not work for the sklearn

sudo apt-get install python3-sklearn

ADDED

When I replace sklearn by scikit-learn, I have the same problem:

Downloading/unpacking scikit-learn
  Cannot fetch index base URL https://pypi.python.org/simple/
  Could not find any downloads that satisfy the requirement scikit-learn
Cleaning up...
No distributions at all found for scikit-learn

ADDED 2

As it has been recommended, I have try to use pip in combination with -vvv. Note that I use pip3 instead of pip. This is what I get as the result:

Downloading/unpacking scikit-learn
  Getting page https://pypi.python.org/simple/scikit-learn/
  Could not fetch URL https://pypi.python.org/simple/scikit-learn/: connection error: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /simple/scikit-learn/ (Caused by <class 'OSError'>: [Errno 101] Network is unreachable)
  Will skip URL https://pypi.python.org/simple/scikit-learn/ when looking for download links for scikit-learn
  Getting page https://pypi.python.org/simple/
  Could not fetch URL https://pypi.python.org/simple/: connection error: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /simple/ (Caused by <class 'OSError'>: [Errno 101] Network is unreachable)
  Will skip URL https://pypi.python.org/simple/ when looking for download links for scikit-learn
  Cannot fetch index base URL https://pypi.python.org/simple/
  URLs to search for versions for scikit-learn:
  * https://pypi.python.org/simple/scikit-learn/
  Getting page https://pypi.python.org/simple/scikit-learn/
  Could not fetch URL https://pypi.python.org/simple/scikit-learn/: connection error: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /simple/scikit-learn/ (Caused by <class 'OSError'>: [Errno 101] Network is unreachable)
  Will skip URL https://pypi.python.org/simple/scikit-learn/ when looking for download links for scikit-learn
  Could not find any downloads that satisfy the requirement scikit-learn
Cleaning up...
  Removing temporary dir /tmp/pip_build_root...
No distributions at all found for scikit-learn
Exception information:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/lib/python3/dist-packages/pip/req.py", line 1178, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 277, in find_requirement
    raise DistributionNotFound('No distributions at all found for %s' % req)
pip.exceptions.DistributionNotFound: No distributions at all found for scikit-learn

Storing debug log for failure in /home/rngorb/.pip/pip.log
7
  • sudo pip install -U pip sudo pip install -U scikit-learn Commented Aug 4, 2016 at 14:30
  • 1
    package name is scikit-learn Commented Aug 4, 2016 at 14:33
  • @Luca, scikit-learn does not work as well (see the update of my question). Commented Aug 4, 2016 at 14:55
  • 1
    Sounds like pip can't find anything on pypi ... Try running sudo pip -vvv install scikit-learn for more diags. Commented Aug 4, 2016 at 23:57
  • 1
    To check the network, you could try pinging pypi.python.org. If that doesn't work, you need to look at your network config. Commented Aug 5, 2016 at 13:00

8 Answers 8

9

Try using

pip3 install scikit-learn
Sign up to request clarification or add additional context in comments.

1 Comment

It does not help, I still have the same problem (the same error message).
2

First update your pip:

pip3 install --upgrade pip

Then install scikit-learn with arg "--user". Don't use sudo with pip as it will give problems:

pip install --user scikit-learn

Comments

1

Maybe you should consider the use of Anaconda which include both packages by default and make your life easy with tools to manage enviroments and packages

1 Comment

@Roman I have also found using Anaconda to be the easiest way to install these packages. Here is an example of using Anaconda to install scikit-learn.
1

I could solve it with this command:

py -m pip install --user NAME_OF_THE_LIBRARY

It worked with- NumPy, SciPy, matplotlib, ipython, jupyter, pandas, sympy, nose and scikit-learn

2 Comments

Are you sure about that? "--user" and "NAME_OF_THE_LIBRARY" seem to not fit
Yes, I am sure. For example para o 'numpy' would be : py -m pip install --user numpy I have installed all libraries exactly this way. The only way that it worked in Python3.
0

If you want the convenience of Anaconda packages but the flexibility and minimalism of pip package management, I suggest you try miniconda.

Once you install miniconda (remembering to source ~/.bash_profile or source ~/.bashrc), you can do this to setup your environment:

conda create -n myenv scikit-learn pip python=3

This will get you a conda env with sklearn and pip in case you want to install libraries that are not supported as a conda package. The pip runs inside the conda env.

Comments

0

Based on this answer for question Python pip error: “Cannot fetch index base URL https://pypi.python.org/simple/” I would try to reinstall (and upgrade) pip with easy_install

easy_install pip==8.1.2

I tried to reproduce your problem, and installing scikit-learn succeeded after pip install numpy and pip install scipy in a virtual environment created by pyenv-3.4.

Comments

0

if you have multiple version of Python, make sure that you are at the correct site-package path before install.

It was the case for me!!!

Comments

0

It works perfectly fine. Try to install sklearn in the global environment i.e. in the terminal directly. For Ubuntu 17.04 (+ latest versions) try-

sudo apt-get install python3-sklearn

Similarly, for pandas

sudo apt-get install python3-pandas

2 Comments

This particularly works for deb based distributions such as Ubunut, Kali-linux, and their flavors. If there is any problem from this commands, let me know.
These are simple apt-get commands to install python libraries, there are other package managers that allows users to download older versions of libraries as well, e.g. conda, alien, etc.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.