当前位置:   article > 正文

cannot import name ‘ssl‘ from ‘urllib3.util.ssl_‘_importerror: cannot import name 'ssl' from 'urllib

importerror: 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提示如下

  1. ImportError Traceback (most recent call last)
  2. <ipython-input-1-e70e92d32c6e> in <module>()
  3. ----> 1 import gensim
  4. D:\anaconda\lib\site-packages\gensim\__init__.py in <module>()
  5. 9 import logging
  6. 10
  7. ---> 11 from gensim import parsing, corpora, matutils, interfaces, models, similarities, utils # noqa:F401
  8. 12
  9. 13
  10. D:\anaconda\lib\site-packages\gensim\parsing\__init__.py in <module>()
  11. 2
  12. 3 from .porter import PorterStemmer # noqa:F401
  13. ----> 4 from .preprocessing import (remove_stopwords, strip_punctuation, strip_punctuation2, # noqa:F401
  14. 5 strip_tags, strip_short, strip_numeric,
  15. 6 strip_non_alphanum, strip_multiple_whitespaces,
  16. D:\anaconda\lib\site-packages\gensim\parsing\preprocessing.py in <module>()
  17. 24 import glob
  18. 25
  19. ---> 26 from gensim import utils
  20. 27 from gensim.parsing.porter import PorterStemmer
  21. 28
  22. D:\anaconda\lib\site-packages\gensim\utils.py in <module>()
  23. 34 import numpy as np
  24. 35 import scipy.sparse
  25. ---> 36 from smart_open import open
  26. 37
  27. 38 from gensim import __version__ as gensim_version
  28. D:\anaconda\lib\site-packages\smart_open\__init__.py in <module>()
  29. 25 from smart_open import version
  30. 26
  31. ---> 27 from .smart_open_lib import open, smart_open, register_compressor
  32. 28 from .s3 import iter_bucket as s3_iter_bucket
  33. 29 __all__ = ['open', 'smart_open', 's3_iter_bucket', 'register_compressor']
  34. D:\anaconda\lib\site-packages\smart_open\smart_open_lib.py in <module>()
  35. 28
  36. 29 import boto
  37. ---> 30 import boto3
  38. 31 import six
  39. 32
  40. D:\anaconda\lib\site-packages\boto3\__init__.py in <module>()
  41. 14 import logging
  42. 15
  43. ---> 16 from boto3.session import Session
  44. 17
  45. 18
  46. D:\anaconda\lib\site-packages\boto3\session.py in <module>()
  47. 15 import os
  48. 16
  49. ---> 17 import botocore.session
  50. 18 from botocore.client import Config
  51. 19 from botocore.exceptions import DataNotFoundError, UnknownServiceError
  52. D:\anaconda\lib\site-packages\botocore\session.py in <module>()
  53. 28 from botocore import UNSIGNED
  54. 29 import botocore.configloader
  55. ---> 30 import botocore.credentials
  56. 31 import botocore.client
  57. 32 from botocore.configprovider import ConfigValueStore
  58. D:\anaconda\lib\site-packages\botocore\credentials.py in <module>()
  59. 32 from botocore.compat import total_seconds
  60. 33 from botocore.compat import compat_shell_split
  61. ---> 34 from botocore.config import Config
  62. 35 from botocore.exceptions import UnknownCredentialError
  63. 36 from botocore.exceptions import PartialCredentialsError
  64. D:\anaconda\lib\site-packages\botocore\config.py in <module>()
  65. 14 from botocore.compat import OrderedDict
  66. 15
  67. ---> 16 from botocore.endpoint import DEFAULT_TIMEOUT, MAX_POOL_CONNECTIONS
  68. 17 from botocore.exceptions import InvalidS3AddressingStyleError
  69. 18 from botocore.exceptions import InvalidRetryConfigurationError
  70. D:\anaconda\lib\site-packages\botocore\endpoint.py in <module>()
  71. 20 from botocore.vendored import six
  72. 21
  73. ---> 22 from botocore.awsrequest import create_request_object
  74. 23 from botocore.exceptions import HTTPClientError
  75. 24 from botocore.httpsession import URLLib3Session
  76. D:\anaconda\lib\site-packages\botocore\awsrequest.py in <module>()
  77. 24 from urllib3.connectionpool import HTTPSConnectionPool
  78. 25
  79. ---> 26 import botocore.utils
  80. 27 from botocore.compat import six
  81. 28 from botocore.compat import HTTPHeaders, HTTPResponse, urlunsplit, urlsplit, \
  82. D:\anaconda\lib\site-packages\botocore\utils.py in <module>()
  83. 29 import botocore
  84. 30 import botocore.awsrequest
  85. ---> 31 import botocore.httpsession
  86. 32 from botocore.compat import json, quote, zip_longest, urlsplit, urlunsplit
  87. 33 from botocore.compat import OrderedDict, six, urlparse
  88. D:\anaconda\lib\site-packages\botocore\httpsession.py in <module>()
  89. 6 from urllib3 import PoolManager, ProxyManager, proxy_from_url, Timeout
  90. 7 from urllib3.util.retry import Retry
  91. ----> 8 from urllib3.util.ssl_ import (
  92. 9 ssl, OP_NO_SSLv2, OP_NO_SSLv3, OP_NO_COMPRESSION, DEFAULT_CIPHERS,
  93. 10 )
  94. ImportError: cannot import name 'ssl' from 'urllib3.util.ssl_' (D:\anaconda\lib\site-packages\urllib3\util\ssl_.py)

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

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/343604
推荐阅读
相关标签
  

闽ICP备14008679号