赞
踩
今天遇到
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)
- <ipython-input-1-e70e92d32c6e> in <module>()
- ----> 1 import gensim
-
- D:\anaconda\lib\site-packages\gensim\__init__.py in <module>()
- 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 <module>()
- 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 <module>()
- 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 <module>()
- 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 <module>()
- 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 <module>()
- 28
- 29 import boto
- ---> 30 import boto3
- 31 import six
- 32
-
- D:\anaconda\lib\site-packages\boto3\__init__.py in <module>()
- 14 import logging
- 15
- ---> 16 from boto3.session import Session
- 17
- 18
-
- D:\anaconda\lib\site-packages\boto3\session.py in <module>()
- 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 <module>()
- 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 <module>()
- 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 <module>()
- 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 <module>()
- 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 <module>()
- 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 <module>()
- 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 <module>()
- 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和下载安装的各种包版本对不上
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。