参考:https://blog.csdn.net/answerxiaoai/article/details/104297187
在安装Google开源维护的算法优化求解器Ortools时出现错误,采用以下方式,则安装成功。
在使用’‘pip install **’'进行安装库的时候会出现报错,像下面这样:
接下来我们处理这个问题,首先再你的Python安装目录下创建一个pip.ini文件
在这里插入图片描述
然后 我们用记事本打开这个pip.ini文件,将下面内容复制进去,然后保存。
在这里插入图片描述
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
trusted-host = mirrors.aliyun.com
其中,index-url = https://pypi.tuna.tsinghua.edu.cn/simple/为国内镜像站,大家也可以使用下边这几个镜像站。
/// 阿里云 https://mirrors.aliyun.com/pypi/simple/
///中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
///豆瓣(douban) https://pypi.douban.com/simple/
///清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
///中国科学技术大学 https://pypi.mirrors.ustc.edu.cn/simple/*
pip.ini文件添加成功后,我们再进行安装,就会发现我们不会再报错了。
pip3 install ortools
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/
Collecting ortools
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9c/3e/9f359269aff8c4195d79486eb7c524658e6dd2ddd393d886e442f4cb0b99/ortools-8.1.8487-cp37-cp37m-win_amd64.whl (41.3 MB)
|████████████████████████████████| 41.3 MB 386 kB/s
Collecting absl-py>=0.11
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/bc/58/0aa6fb779dc69cfc811df3398fcbeaeefbf18561b6e36b185df0782781cc/absl_py-0.11.0-py3-none-any.whl (127 kB)
|████████████████████████████████| 127 kB 3.3 MB/s
Requirement already satisfied: six in d:\program software\pythhon-3.7\lib\site-packages (from absl-py>=0.11->ortools) (1.14.0)
Collecting protobuf>=3.14.0
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1d/f4/089025cfa3ee62f89cae73f4d36daf46f339c6df61becfe4b24f3aeb3c0d/protobuf-3.14.0-cp37-cp37m-win_amd64.whl (798 kB)
|████████████████████████████████| 798 kB 3.3 MB/s
Installing collected packages: protobuf, absl-py, ortools
Successfully installed absl-py-0.11.0 ortools-8.1.8487 protobuf-3.14.0