我尝试为Python 3安装scikit-learn。我是按照以下方式安装的:
virtualenv model_env
source model_env/bin/activate
pip3 install sklearn
结果我收到以下错误消息:
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
我对pandas
包有同样的问题,我已使用以下命令解决了这个问题:
sudo apt-get install python3-pandas
不幸的是,同样的方法对sklearn
sudo apt-get install python3-sklearn
ADDED
当我将sklearn
替换为scikit-learn
时,我遇到了同样的问题:
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
已添加2
正如我们所推荐的那样,我尝试将pip与-vvv
结合使用。请注意,我使用的是pip3
而不是pip
。这就是我得到的结果:
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
答案 0 :(得分:9)
尝试使用
pip3 install scikit-learn
答案 1 :(得分:2)
首先更新你的点子:
pip3 install --upgrade pip
然后使用arg“--user”安装scikit-learn。不要使用带有pip的sudo,因为它会产生问题:
pip install --user scikit-learn
答案 2 :(得分:1)
也许您应该考虑使用Anaconda默认包含这两个软件包,并使用工具来管理enviroments和packages
答案 3 :(得分:1)
我可以用这个命令解决它:
py -m pip install --user NAME_OF_THE_LIBRARY
它适用于 - NumPy,SciPy,matplotlib,ipython,jupyter,pandas,sympy,nose和scikit-learn
答案 4 :(得分:0)
如果您想要Anaconda套餐的便利性,但pip
套餐管理的灵活性和极简主义,我建议您尝试miniconda。
安装miniconda后(记得source ~/.bash_profile
或source ~/.bashrc
),您可以这样做来设置您的环境:
conda create -n myenv scikit-learn pip python=3
如果你想安装不支持作为conda包的库,这将为你提供一个带有sklearn和pip的conda env。 pip在conda env内部运行。
答案 5 :(得分:0)
根据问题answer Python pip error: “Cannot fetch index base URL https://pypi.python.org/simple/”,我会尝试使用easy_install重新安装(和升级)pip
easy_install pip==8.1.2
我尝试重现您的问题,并且在pyenv-3.4创建的虚拟环境中,pip install numpy
和pip install scipy
之后安装scikit-learn成功。
答案 6 :(得分:0)
如果您有多个版本的Python,请确保在安装之前您处于正确的站点包路径。
我的情况就是这样!!!
答案 7 :(得分:0)
效果很好。尝试在全局环境(即直接在终端)中安装sklearn。对于Ubuntu 17.04(+最新版本),请尝试-
sudo apt-get install python3-sklearn
类似地,对于熊猫
sudo apt-get install python3-pandas