[英]“Cannot fetch index base URL” error message when attempting to install scikit-learn for Python 3
I try to install scikit-learn for Python 3. I do it in the following way: 我尝试为python 3安装scikit-learn。我通过以下方式进行安装:
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: 我在使用
pandas
软件包时遇到了同样的问题,并通过使用以下命令解决了该问题:
sudo apt-get install python3-pandas
Unfortunately, the same approach does not work for the sklearn
不幸的是,相同的方法不适用于
sklearn
sudo apt-get install python3-sklearn
ADDED 添加
When I replace sklearn
by scikit-learn
, I have the same problem: 当我用
scikit-learn
替换sklearn
时,我sklearn
了同样的问题:
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 加了2
As it has been recommended, I have try to use pip in combination with -vvv
. 根据建议,我尝试将pip与
-vvv
结合使用。 Note that I use pip3
instead of pip
. 请注意,我使用的是
pip3
而不是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
尝试使用
pip3 install scikit-learn
First update your pip: 首先更新您的点数:
pip3 install --upgrade pip
Then install scikit-learn with arg "--user". 然后用arg“ --user”安装scikit-learn。 Don't use sudo with pip as it will give problems:
不要将sudo与pip一起使用,因为它会带来问题:
pip install --user scikit-learn
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 它适用于-NumPy,SciPy,matplotlib,ipython,jupyter,pandas,sympy,nose和scikit-learn
If you want the convenience of Anaconda packages but the flexibility and minimalism of pip
package management, I suggest you try miniconda . 如果您想要Anaconda软件包的便利性,但是希望
pip
软件包管理的灵活性和极简主义,我建议您尝试miniconda 。
Once you install miniconda (remembering to source ~/.bash_profile
or source ~/.bashrc
), you can do this to setup your environment: 一旦安装了miniconda(记住
source ~/.bash_profile
或source ~/.bashrc
),您可以执行以下操作来设置您的环境:
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. 如果您要安装不支持作为conda软件包的库,这将为您提供带有sklearn和pip的conda env。 The pip runs inside the conda env.
点子在conda env内部运行。
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 基于以下问题的答案 Python pip错误:“无法获取索引库URL https://pypi.python.org/simple/”,我将尝试使用easy_install重新安装(和升级)pip
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. 我试图重现您的问题,在pyenv-3.4创建的虚拟环境中
pip install numpy
和pip install scipy
之后成功安装了scikit-learn。
if you have multiple version of Python, make sure that you are at the correct site-package path before install. 如果您有多个版本的Python,请在安装前确保您位于正确的站点程序包路径中。
It was the case for me!!! 对我来说就是这样!
It works perfectly fine. 它工作得很好。 Try to install sklearn in the global environment ie in the terminal directly.
尝试在全局环境(即直接在终端)中安装sklearn。 For Ubuntu 17.04 (+ latest versions) try-
对于Ubuntu 17.04(+最新版本),请尝试-
sudo apt-get install python3-sklearn
Similarly, for pandas 同样,对于熊猫
sudo apt-get install python3-pandas
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.