环境:deepin15+Anaconda3,在执行pip时报错如下:
Traceback (most recent call last):
File "/usr/share/Anaconda3/bin/pip", line 7, in
from pip._internal import main
File "/usr/share/Anaconda3/lib/python3.6/site-packages/pip/_internal/__init__.py", line 42, in
from pip._internal import cmdoptions
File "/usr/share/Anaconda3/lib/python3.6/site-packages/pip/_internal/cmdoptions.py", line 16, in
from pip._internal.index import (
File "/usr/share/Anaconda3/lib/python3.6/site-packages/pip/_internal/index.py", line 15, in
from pip._vendor import html5lib, requests, six
File "/usr/share/Anaconda3/lib/python3.6/site-packages/pip/_vendor/requests/__init__.py", line 86, in
from pip._vendor.urllib3.contrib import pyopenssl
File "/usr/share/Anaconda3/lib/python3.6/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in
import OpenSSL.SSL
File "/usr/share/Anaconda3/lib/python3.6/site-packages/OpenSSL/__init__.py", line 8, in
from OpenSSL import crypto, SSL
File "/usr/share/Anaconda3/lib/python3.6/site-packages/OpenSSL/crypto.py", line 12, in
from cryptography import x509
File "/usr/share/Anaconda3/lib/python3.6/site-packages/cryptography/x509/__init__.py", line 8, in
from cryptography.x509.base import (
File "/usr/share/Anaconda3/lib/python3.6/site-packages/cryptography/x509/base.py", line 16, in
from cryptography.x509.extensions import Extension, ExtensionType
File "/usr/share/Anaconda3/lib/python3.6/site-packages/cryptography/x509/extensions.py", line 13, in
from asn1crypto.keys import PublicKeyInfo
File "/usr/share/Anaconda3/lib/python3.6/site-packages/asn1crypto/keys.py", line 22, in
from ._elliptic_curve import (
File "/usr/share/Anaconda3/lib/python3.6/site-packages/asn1crypto/_elliptic_curve.py", line 51, in
from ._int import inverse_mod
File "/usr/share/Anaconda3/lib/python3.6/site-packages/asn1crypto/_int.py", line 52, in
if platform.python_implementation() == 'PyPy':
File "/usr/share/Anaconda3/lib/python3.6/platform.py", line 1257, in python_implementation
return _sys_version()[0]
File "/usr/share/Anaconda3/lib/python3.6/platform.py", line 1215, in _sys_version
repr(sys_version))
ValueError: failed to parse CPython sys.version: '3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19) \n[GCC 7.2.0]'
/usr/share/Anaconda3/lib/python3.6/platform.py:1215:
发现此正则表达式未考虑Anaconda增加了"|Anaconda, Inc.|"的问题,需要过滤掉.
在_sys_version_parser中增加一行过滤掉"|Anaconda xxx|"等信息即可: