cannot import name ‘ssl‘ from ‘urllib3.util.ssl_‘

今天遇到

cannot import name 'ssl' from 'urllib3.util.ssl_' 这个bug,经过检查,这个bug由于代码
import gensim引起的
https://stackoverflow.com/questions/58544638/importerror-cannot-import-name-ssl-from-urllib3-util-ssl
这个网页提出降版本的方法,我试了一下,这个方法是可行的,但是python不能随便降版本,容易捡了芝麻,丢了西瓜。
https://www.jianshu.com/p/118affa2ebd3
这个网页提出安装openssl,下载和安装,这个方法是没有用的,可能我现在的问题不是这个方面。

bug提示如下

ImportError                               Traceback (most recent call last)
 in ()
----> 1 import gensim

D:\anaconda\lib\site-packages\gensim\__init__.py in ()
      9 import logging
     10 
---> 11 from gensim import parsing, corpora, matutils, interfaces, models, similarities, utils  # noqa:F401
     12 
     13 

D:\anaconda\lib\site-packages\gensim\parsing\__init__.py in ()
      2 
      3 from .porter import PorterStemmer  # noqa:F401
----> 4 from .preprocessing import (remove_stopwords, strip_punctuation, strip_punctuation2,  # noqa:F401
      5                             strip_tags, strip_short, strip_numeric,
      6                             strip_non_alphanum, strip_multiple_whitespaces,

D:\anaconda\lib\site-packages\gensim\parsing\preprocessing.py in ()
     24 import glob
     25 
---> 26 from gensim import utils
     27 from gensim.parsing.porter import PorterStemmer
     28 

D:\anaconda\lib\site-packages\gensim\utils.py in ()
     34 import numpy as np
     35 import scipy.sparse
---> 36 from smart_open import open
     37 
     38 from gensim import __version__ as gensim_version

D:\anaconda\lib\site-packages\smart_open\__init__.py in ()
     25 from smart_open import version
     26 
---> 27 from .smart_open_lib import open, smart_open, register_compressor
     28 from .s3 import iter_bucket as s3_iter_bucket
     29 __all__ = ['open', 'smart_open', 's3_iter_bucket', 'register_compressor']

D:\anaconda\lib\site-packages\smart_open\smart_open_lib.py in ()
     28 
     29 import boto
---> 30 import boto3
     31 import six
     32 

D:\anaconda\lib\site-packages\boto3\__init__.py in ()
     14 import logging
     15 
---> 16 from boto3.session import Session
     17 
     18 

D:\anaconda\lib\site-packages\boto3\session.py in ()
     15 import os
     16 
---> 17 import botocore.session
     18 from botocore.client import Config
     19 from botocore.exceptions import DataNotFoundError, UnknownServiceError

D:\anaconda\lib\site-packages\botocore\session.py in ()
     28 from botocore import UNSIGNED
     29 import botocore.configloader
---> 30 import botocore.credentials
     31 import botocore.client
     32 from botocore.configprovider import ConfigValueStore

D:\anaconda\lib\site-packages\botocore\credentials.py in ()
     32 from botocore.compat import total_seconds
     33 from botocore.compat import compat_shell_split
---> 34 from botocore.config import Config
     35 from botocore.exceptions import UnknownCredentialError
     36 from botocore.exceptions import PartialCredentialsError

D:\anaconda\lib\site-packages\botocore\config.py in ()
     14 from botocore.compat import OrderedDict
     15 
---> 16 from botocore.endpoint import DEFAULT_TIMEOUT, MAX_POOL_CONNECTIONS
     17 from botocore.exceptions import InvalidS3AddressingStyleError
     18 from botocore.exceptions import InvalidRetryConfigurationError

D:\anaconda\lib\site-packages\botocore\endpoint.py in ()
     20 from botocore.vendored import six
     21 
---> 22 from botocore.awsrequest import create_request_object
     23 from botocore.exceptions import HTTPClientError
     24 from botocore.httpsession import URLLib3Session

D:\anaconda\lib\site-packages\botocore\awsrequest.py in ()
     24 from urllib3.connectionpool import HTTPSConnectionPool
     25 
---> 26 import botocore.utils
     27 from botocore.compat import six
     28 from botocore.compat import HTTPHeaders, HTTPResponse, urlunsplit, urlsplit, \

D:\anaconda\lib\site-packages\botocore\utils.py in ()
     29 import botocore
     30 import botocore.awsrequest
---> 31 import botocore.httpsession
     32 from botocore.compat import json, quote, zip_longest, urlsplit, urlunsplit
     33 from botocore.compat import OrderedDict, six, urlparse

D:\anaconda\lib\site-packages\botocore\httpsession.py in ()
      6 from urllib3 import PoolManager, ProxyManager, proxy_from_url, Timeout
      7 from urllib3.util.retry import Retry
----> 8 from urllib3.util.ssl_ import (
      9     ssl, OP_NO_SSLv2, OP_NO_SSLv3, OP_NO_COMPRESSION, DEFAULT_CIPHERS,
     10 )

ImportError: cannot import name 'ssl' from 'urllib3.util.ssl_' (D:\anaconda\lib\site-packages\urllib3\util\ssl_.py)

经过反复挣扎,最后还是重装了python。。。

因为这个bug的本质是python和下载安装的各种包版本对不上

你可能感兴趣的:(基本神经网络,python)