You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在虚拟机中安装requests-ntlm2?Django项目安装失败求助

解决Python2.7 Django项目安装requests-ntlm2失败的问题

问题重现

在基于Python2.7.17的Django项目中尝试安装requests-ntlm2时,出现连接超时及找不到包的错误,报错信息如下:

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x7f7c928569d0>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/requests-ntlm2/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x7f7c92856880>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/requests-ntlm2/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x7f7c92856610>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/requests-ntlm2/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x7f7c928565b0>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/requests-ntlm2/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x7f7c928564f0>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/requests-ntlm2/
ERROR: Could not find a version that satisfies the requirement requests-ntlm2 (from versions: none)
ERROR: No matching distribution found for requests-ntlm2

中文翻译:

警告:连接pypi.org超时(连接超时=15)导致连接中断后,正在重试(剩余重试次数4):/simple/requests-ntlm2/
警告:连接pypi.org超时(连接超时=15)导致连接中断后,正在重试(剩余重试次数3):/simple/requests-ntlm2/
警告:连接pypi.org超时(连接超时=15)导致连接中断后,正在重试(剩余重试次数2):/simple/requests-ntlm2/
警告:连接pypi.org超时(连接超时=15)导致连接中断后,正在重试(剩余重试次数1):/simple/requests-ntlm2/
警告:连接pypi.org超时(连接超时=15)导致连接中断后,正在重试(剩余重试次数0):/simple/requests-ntlm2/
错误:找不到满足requests-ntlm2要求的版本(可用版本:无)
错误:未找到匹配requests-ntlm2的发行版

解决方案

1. 修复网络连接问题

  • 使用国内PyPI镜像源:由于官方PyPI连接超时,切换到国内镜像(如豆瓣)安装:
    pip install requests-ntlm2 -i https://pypi.douban.com/simple/
    
  • 配置代理(如果需要):如果你的网络需要代理访问外部资源,添加代理参数:
    pip install requests-ntlm2 --proxy=http://你的代理地址:端口
    

2. 替换为兼容Python2.7的替代包

requests-ntlm2可能已停止维护或不支持Python2.7,建议使用官方维护的requests-ntlm包,它完全兼容Python2.7:

pip install requests-ntlm

3. 手动本地安装

如果网络问题无法解决,可手动下载包文件后本地安装:

  1. 下载requests-ntlm2的源码包(.tar.gz)或对应Python2.7的wheel包(.whl)
  2. 执行本地安装命令:
    • 对于wheel包:
      pip install /path/to/requests-ntlm2-xxx.whl
      
    • 对于源码包:
      tar -zxvf requests-ntlm2-xxx.tar.gz
      cd requests-ntlm2-xxx
      python setup.py install
      

内容的提问来源于stack exchange,提问作者Sakthi Priya

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 03:39:55