首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >pip install 走公网到files.pythonhosted.org 跨境质量差,用内网源没问题

pip install 走公网到files.pythonhosted.org 跨境质量差,用内网源没问题

原创
作者头像
Windows技术交流
修改2024-01-15 18:26:11
修改2024-01-15 18:26:11
68000
代码可运行
举报
文章被收录于专栏:Windows技术交流Windows技术交流
运行总次数:0
代码可运行
代码语言:javascript
代码运行次数:0
运行
复制
问题描述:pip install coscmd报错访问到不了python源files.pythonhosted.org
问题原因:走公网到python源跨境质量差
解决办法:用内网源,可靠稳定

pip install coscmd -i http://mirrors.tencentyun.com/pypi/simple --trusted-host mirrors.tencentyun.com
pip install coscmd -U -i http://mirrors.tencentyun.com/pypi/simple --trusted-host mirrors.tencentyun.com

走公网到files.pythonhosted.org 跨境质量差,我这边也复现,用内网源没问题

cloudbase-init自带python
powershell命令切换到pip目录:

cd "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Scripts"
cmd.exe /c mklink "c:\python_cloudbaseinit" "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\"  /D 2>$null

公网源和内网源对比:
c:\python_cloudbaseinit\python.exe -m pip install --upgrade pip
c:\python_cloudbaseinit\python.exe -m pip install --upgrade pip -i http://mirrors.tencentyun.com/pypi/simple  --trusted-host mirrors.tencentyun.com

腾讯云基于Windows公共镜像的机器有cloudbase-init,由于cloudbase-init自带python环境,只需要简单处理下环境变量就可以指定内网源来安装coscmd

懒人直接复制粘贴这段代码即可

代码语言:javascript
代码运行次数:0
运行
复制
#ps1
cmd.exe /c mklink "c:\python_cloudbaseinit" "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\"  /D 2>$null
wget http://windows-1251783334.cos.ap-shanghai.myqcloud.com/pathman.exe -Outfile c:\windows\pathman.exe
pathman /as "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python;C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Scripts"

& "c:\python_cloudbaseinit\python.exe" -m pip install --upgrade pip -i http://mirrors.tencentyun.com/pypi/simple  --trusted-host mirrors.tencentyun.com
& "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\pip.exe" install coscmd -i http://mirrors.tencentyun.com/pypi/simple --trusted-host mirrors.tencentyun.com
& "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\pip.exe" install coscmd -U -i http://mirrors.tencentyun.com/pypi/simple --trusted-host mirrors.tencentyun.com

exit

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档