windows电脑pip安装报错的最终解决方案。

一、问题:

今天不知道怎么了,我使用pip安装各种模块,都报错,始终没有解决,没有办法,把pip重新卸载安装了好几个版本,还是不行。

现在这个是最后一个pip版本的报错,实在弄了太久了,找到一个python安装解压包安装的方法。

C:\>pip install httpheader
Collecting httpheader
  Using cached httpheader-1.1.tar.gz (30 kB)
ERROR: Exception:
Traceback (most recent call last):
  File "D:\python_work_tools\python3.6.8\lib\site-packages\pip\_internal\cli\base_command.py", line 216, in _main
    status = self.run(options, args)
  File "D:\python_work_tools\python3.6.8\lib\site-packages\pip\_internal\cli\req_command.py", line 182, in wrapper
    return func(self, options, args)
  File "D:\python_work_tools\python3.6.8\lib\site-packages\pip\_internal\commands\install.py", line 325, in run
    reqs, check_supported_wheels=not options.target_dir
  File "D:\python_work_tools\python3.6.8\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 183, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "D:\python_work_tools\python3.6.8\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 388, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "D:\python_work_tools\python3.6.8\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 340, in _get_abstract_dist_for
    abstract_dist = self.preparer.prepare_linked_requirement(req)
  File "D:\python_work_tools\python3.6.8\lib\site-packages\pip\_internal\operations\prepare.py", line 483, in prepare_linked_requirement
    req, self.req_tracker, self.finder, self.build_isolation,
  File "D:\python_work_tools\python3.6.8\lib\site-packages\pip\_internal\operations\prepare.py", line 91, in _get_prepared_distribution
    abstract_dist.prepare_distribution_metadata(finder, build_isolation)
  File "D:\python_work_tools\python3.6.8\lib\site-packages\pip\_internal\distributions\sdist.py", line 40, in prepare_distribution_metadata
    self.req.prepare_metadata()
  File "D:\python_work_tools\python3.6.8\lib\site-packages\pip\_internal\req\req_install.py", line 554, in prepare_metadata
    self.metadata_directory = self._generate_metadata()
  File "D:\python_work_tools\python3.6.8\lib\site-packages\pip\_internal\req\req_install.py", line 534, in _generate_metadata
    details=self.name or "from {}".format(self.link)
  File "D:\python_work_tools\python3.6.8\lib\site-packages\pip\_internal\operations\build\metadata_legacy.py", line 73, in generate_metadata
    command_desc='python setup.py egg_info',
  File "D:\python_work_tools\python3.6.8\lib\site-packages\pip\_internal\utils\subprocess.py", line 200, in call_subprocess
    line = console_to_str(proc.stdout.readline())
  File "D:\python_work_tools\python3.6.8\lib\codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 18: invalid continuation byte

二、几个小点

每次找,太麻烦,我把我今天卸载安装pip的方法记下来吧。有需要也可以参考参考。

1、windows卸载pip

python -m pip uninstall pip

我卸载之后发现,python安装目录下的Scripts目录中还有残留,决定彻底删除测试。

我的安装目录 D:\python_work_tools\python3.6.8\Scripts

在这里插入图片描述

2、更新pip

python -m pip install --upgrade pip

3、安装pip

找到自己想安装的pip版本:
我安装的地址:https://pypi.org/project/pip/19.2/

在这里插入图片描述

中间的 Release history是pip的所以版本,也可以自己选择。

扫描二维码关注公众号,回复: 11745602 查看本文章

点击Download files 下载,下载gz的模块压缩包。
在这里插入图片描述
然后解压。进入解压目录。

然后cmd或者powershell进入解压目录,

 python setup.py install

在这里插入图片描述

三、解决其他模块的安装问题:

我也不知道,我的公司电脑突然怎么了,今天突然安装不了模块了。然后根据上面安装pip的步骤,觉得其他的模块看也可以,结果安装就成功了。

这个步骤我就不截图了,根据上面的安装pip的步骤,安装其他模块即可。
感觉一时半会也不好了,先将就这使用下载gz的压缩包安装模块吧。

猜你喜欢

转载自blog.csdn.net/weixin_42081389/article/details/108407347