vscode 如何运行pip_vscode执行pip指令出现code for hash md5 was not found报错

在MacOS上使用vscode和Python插件时,尝试通过pip安装openpyxl遇到问题,提示code for hash md5 was not found。已知系统中有Python2和Python3,且pip3安装正常,但通过pip升级pip时出现下载超时错误。错误堆栈显示与hashlib和urllib3有关,提示找不到sha512和md5模块。
摘要由CSDN通过智能技术生成

问题描述

刚开始学习Python,为了图个方便就在vscode上安装Python插件直接写文件了,在执行pip install openpyxl的时候出现报错:code for hash md5 was not found报错。

问题出现的平台版本及自己尝试过哪些方法

MacOS 10.15.3

vscode 1.42.2

2020.05.07更新:

从终端看已经安装了python3和pip3,但是Mac自带python2,我不清楚现在到底是哪个版本在工作。

在终端尝试pip3 install openpyxl没有报错,但是显示需要通过pip install --upgrade pip升级pip,当然如果执行pip指令还是不能识别,于是我尝试了pip3 install --upgrade pip下载到8%出现报错:

Collecting pip

Downloading https://files.pythonhosted.org/packages/54/2e/df11ea7e23e7e761d484ed3740285a34e38548cf2bad2bed3dd5768ec8b9/pip-20.1-py2.py3-none-any.whl (1.5MB)

8% |██▉ | 133kB 6.7kB/s eta 0:03:22Exception:

Traceback (most recent call last):

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 360, in _error_catcher

yield

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 442, in read

data = self._fp.read(amt)

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 62, in read

data = self.__fp.read(amt)

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 447, in read

n = self.readinto(b)

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 491, in readinto

n = self.fp.readinto(b)

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/socket.py", line 589, in readinto

return self._sock.recv_into(b)

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ssl.py", line 1052, in recv_into

return self.read(nbytes, buffer)

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ssl.py", line 911, in read

return self._sslobj.read(len, buffer)

socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 179, in main

status = self.run(options, args)

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 315, in run

resolver.resolve(requirement_set)

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/resolve.py", line 131, in resolve

self._resolve_one(requirement_set, req)

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/resolve.py", line 294, in _resolve_one

abstract_dist = self._get_abstract_dist_for(req_to_install)

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/resolve.py", line 242, in _get_abstract_dist_for

self.require_hashes

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 334, in prepare_linked_requirement

progress_bar=self.progress_bar

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/download.py", line 878, in unpack_url

progress_bar=progress_bar

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/download.py", line 702, in unpack_http_url

progress_bar)

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/download.py", line 946, in _download_http_url

_download_url(resp, link, content_file, hashes, progress_bar)

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/download.py", line 639, in _download_url

hashes.check_against_chunks(downloaded_chunks)

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/utils/hashes.py", line 62, in check_against_chunks

for chunk in chunks:

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/download.py", line 607, in written_chunks

for chunk in chunks:

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/utils/ui.py", line 159, in iter

for x in it:

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/download.py", line 596, in resp_read

decode_content=False):

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 494, in stream

data = self.read(amt=amt, decode_content=decode_content)

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 459, in read

raise IncompleteRead(self._fp_bytes_read, self.length_remaining)

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/contextlib.py", line 130, in __exit__

self.gen.throw(type, value, traceback)

File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip/_vendor/urllib3/response.py", line 365, in _error_catcher

raise ReadTimeoutError(self._pool, None, 'Read timed out.')

pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

You are using pip version 19.0.3, however version 20.1 is available.

You should consider upgrading via the 'pip install --upgrade pip' command.

相关代码

具体报错内容:

ERROR:root:code for hash sha512 was not found.

Traceback (most recent call last):

File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in

globals()[__func_name] = __get_hash(__func_name)

File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor

raise ValueError('unsupported hash type ' + name)

ValueError: unsupported hash type sha512

Traceback (most recent call last):

File "/usr/local/bin/pip", line 11, in

load_entry_point('pip==19.0.3', 'console_scripts', 'pip')()

File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point

return get_distribution(dist).load_entry_point(group, name)

File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2793, in load_entry_point

return ep.load()

File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2411, in load

return self.resolve()

File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2417, in resolve

module = __import__(self.module_name, fromlist=['__name__'], level=0)

File "/usr/local/lib/python2.7/site-packages/pip/_internal/__init__.py", line 19, in

from pip._vendor.urllib3.exceptions import DependencyWarning

File "/usr/local/lib/python2.7/site-packages/pip/_vendor/urllib3/__init__.py", line 8, in

from .connectionpool import (

File "/usr/local/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.py", line 29, in

from .connection import (

File "/usr/local/lib/python2.7/site-packages/pip/_vendor/urllib3/connection.py", line 38, in

from .util.ssl_ import (

File "/usr/local/lib/python2.7/site-packages/pip/_vendor/urllib3/util/__init__.py", line 6, in

from .ssl_ import (

File "/usr/local/lib/python2.7/site-packages/pip/_vendor/urllib3/util/ssl_.py", line 8, in

from hashlib import md5, sha1, sha256

ImportError: cannot import name md5

你期待的结果是什么?实际看到的错误信息又是什么?

有没有大神指点下怎么能够正常的使用pip指令,谢谢!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值