python——pip问题

报错信息如下:

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1074: The handshake operation timed out'))': /pypi/simple/tensorflow-cpu/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1074: The handshake operation timed out'))': /pypi/simple/tensorflow-cpu/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1074: The handshake operation timed out'))': /pypi/simple/tensorflow-cpu/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1074: The handshake operation timed out'))': /pypi/simple/tensorflow-cpu/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1074: The handshake operation timed out'))': /pypi/simple/tensorflow-cpu/
ERROR: Could not find a version that satisfies the requirement tensorflow-cpu==2.1.0
ERROR: No matching distribution found for tensorflow-cpu==2.1.0

 

解决方案:

pip install matplotlib-i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com

下面是收集的一些国内的pip源:阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 
豆瓣(douban) http://pypi.douban.com/simple/ 
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

如果想要永久修改pip源,可按照如下操作:

Windows:

1.找到系统盘下C:\Users\用户名\AppData\Roaming

2.查看在Roaming文件夹下有没有一个pip文件夹,如果没有创建一个;

3.进入pip文件夹,创建一个pip.ini文件;

4.使用记事本的方式打开pip.ini文件,写入:

[global]
index-url = http://mirrors.aliyun.com/pypi/simple  # 指定下载源
trusted-host = mirrors.aliyun.com             # 指定域名

Linux:

# 找到~/.pip/pip.conf,如果不存在就创建,加入内容如下 
[global]
timeout = 10 # 设置超时,单位s
index-url =  http://mirrors.aliyun.com/pypi/simple/   # 指定优先下载源
extra-index-url= http://pypi.douban.com/simple/   # 第二下载源
[install]
trusted-host=
    mirrors.aliyun.com
    pypi.douban.com

我在尝试的过程发现如下报错:

E:\Python_papers>pip install pyl
Looking in indexes: http://mirrors.aliyun.com/pypi/simple
WARNING: The repository located at mirrors.aliyun.com is not a trusted or secure host an
d is being ignored. If this repository is available via HTTPS we recommend you use HTTPS
 instead, otherwise you may silence this warning and allow it anyway with '--trusted-hos
t mirrors.aliyun.com'.
ERROR: Could not find a version that satisfies the requirement pyl (from versions: none)

ERROR: No matching distribution found for pyl

解决方案如下:

pip install ××× -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

成功解决问题如下图:

​​​​​​​

 

PS C:\WINDOWS\system32> Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) Forcing web requests to allow TLS v1.2 (Required for requests to Chocolatey.org) Getting latest version of the Chocolatey package for download. Not using proxy. Getting Chocolatey from https://community.chocolatey.org/api/v2/package/chocolatey/2.0.0. Downloading https://community.chocolatey.org/api/v2/package/chocolatey/2.0.0 to C:\Users\27748\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip Not using proxy. Extracting C:\Users\27748\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip to C:\Users\27748\AppData\Local\Temp\chocolatey\chocoInstall Installing Chocolatey on the local machine Creating ChocolateyInstall as an environment variable (targeting 'Machine') Setting ChocolateyInstall to 'C:\ProgramData\chocolatey' WARNING: It's very likely you will need to close and reopen your shell before you can use choco. Restricting write permissions to Administrators We are setting up the Chocolatey package repository. The packages themselves go to 'C:\ProgramData\chocolatey\lib' (i.e. C:\ProgramData\chocolatey\lib\yourPackageName). A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin' and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'. Creating Chocolatey folders if they do not already exist. chocolatey.nupkg file not installed in lib. Attempting to locate it from bootstrapper. PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding... 警告: Not setting tab completion: Profile file does not exist at 'C:\Users\27748\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'. Chocolatey (choco.exe) is now ready. You can call choco from anywhere, command line or powershell by typing choco. Run choco /? for a list of functions. You may need to shut down and restart powershell and/or consoles first prior to using choco. Ensuring Chocolatey commands are on the path Ensuring chocolatey.nupkg is in the lib folder PS C:\WINDOWS\system32>
06-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值