<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/ DTD/wml_1.1.xml">

<wml>
<head>
<meta http-equiv="cache-control" content="max-age=180,private" />
</head>
<card title="python3安装pip3">
<p>
作者:<a href="index.php?action=showuser&amp;userid=1&amp;hash=">admin</a><br />时间:2021-11-13 07:50<br />分类:<a href="index.php?action=list&amp;cid=3&amp;hash=">电脑技术</a><br />内容:
python3安装pip3


python运行错误

python报错ModuleNotFoundError: No module named 'httplib'

缺乏&rsquo;httplib&rsquo;包pip install &ndash;upgrade pip`

响应


Could not find a version that satisfies the requirement httplib (from versions: )

No matching distribution found for httplib

更新pip


pip install --upgrade pip


查看pip版本


pip -V


pip 19.1.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)

更新pip为pip3


curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py


# 注意如果python有多个版本，用python3


python3 get-pip.py


pip -V


//pip 19.1.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

错误解决

仍然报错ModuleNotFoundError: No module named 'httplib'

查找到stack overflow文章中指出

You are running Python 2 code on Python 3. In Python 3, the module has been renamed to http.client.

这是python2的代码，不能用python3运行

You could try to run the 2to3 tool on your code, and try to have it translated automatically. References to httplib will automatically be rewritten to use http.client instead.
</p><p>
<a href="index.php?action=login&amp;hash=">立即登陆发表评论</a><br />
</p>
<p><a href="index.php?action=list&amp;hash=">返回日志列表</a><br /><a href="index.php?action=index&amp;hash=">返回主页</a></p>
</card>
</wml>
