代码语言:javascript复制
问题描述: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 FilesCloudbase SolutionsCloudbase-InitPythonScripts"
cmd.exe /c mklink "c:python_cloudbaseinit" "C:Program FilesCloudbase SolutionsCloudbase-InitPython" /D 2>$null
公网源和内网源对比:
c:python_cloudbaseinitpython.exe -m pip install --upgrade pip
c:python_cloudbaseinitpython.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复制#ps1
cmd.exe /c mklink "c:python_cloudbaseinit" "C:Program FilesCloudbase SolutionsCloudbase-InitPython" /D 2>$null
wget http://windows-1251783334.cos.ap-shanghai.myzijiebao.com/pathman.exe -Outfile c:windowspathman.exe
pathman /as "C:Program FilesCloudbase SolutionsCloudbase-InitPython;C:Program FilesCloudbase SolutionsCloudbase-InitPythonScripts"
& "c:python_cloudbaseinitpython.exe" -m pip install --upgrade pip -i http://mirrors.tencentyun.com/pypi/simple --trusted-host mirrors.tencentyun.com
& "C:Program FilesCloudbase SolutionsCloudbase-InitPythonScriptspip.exe" install coscmd -i http://mirrors.tencentyun.com/pypi/simple --trusted-host mirrors.tencentyun.com
& "C:Program FilesCloudbase SolutionsCloudbase-InitPythonScriptspip.exe" install coscmd -U -i http://mirrors.tencentyun.com/pypi/simple --trusted-host mirrors.tencentyun.com
exit