ImportError: cannot import name 'ssl' from 'urllib3.util.ssl_'
ImportError: cannot import name 'ssl' from 'urllib3.util.ssl_'
我正在尝试从 cmd 启动 python 代码。我使用 python 3.7 和 Anaconda。我最初有一个 DLL 问题。根据论坛中的一些答案,我在 Windows OS 上的环境变量中插入了路径“C:\Users\andre\Anaconda3\envs\py37\Library\bin”。之后我遇到了以下错误:
Traceback (most recent call last):
File "C:\Users\andre\Documents\NetBeansProjects\Aladin_demo\py\get_class.py", line 8, in <module>
import gensim
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\gensim\__init__.py", line 5, in <module>
from gensim import parsing, corpora, matutils, interfaces, models, similarities, summarization, utils # noqa:F401
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\gensim\parsing\__init__.py", line 4, in <module>
from .preprocessing import (remove_stopwords, strip_punctuation, strip_punctuation2, # noqa:F401
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\gensim\parsing\preprocessing.py", line 42, in <module>
from gensim import utils
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\gensim\utils.py", line 45, in <module>
from smart_open import open
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\smart_open\__init__.py", line 28, in <module>
from .smart_open_lib import open, smart_open, register_compressor
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\smart_open\smart_open_lib.py", line 40, in <module>
import boto3
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\boto3\__init__.py", line 16, in <module>
from boto3.session import Session
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\boto3\session.py", line 17, in <module>
import botocore.session
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\botocore\session.py", line 30, in <module>
import botocore.credentials
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\botocore\credentials.py", line 34, in <module>
from botocore.config import Config
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\botocore\config.py", line 16, in <module>
from botocore.endpoint import DEFAULT_TIMEOUT, MAX_POOL_CONNECTIONS
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\botocore\endpoint.py", line 22, in <module>
from botocore.awsrequest import create_request_object
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\botocore\awsrequest.py", line 26, in <module>
import botocore.utils
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\botocore\utils.py", line 31, in <module>
import botocore.httpsession
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\botocore\httpsession.py", line 7, in <module>
from urllib3.util.ssl_ import (
ImportError: cannot import name 'ssl' from 'urllib3.util.ssl_' (C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\urllib3\util\ssl_.py)
当我在我的 Jupyter Notebook 中 运行 我的脚本时,我没有看到这个错误消息,但是当我在命令行上 运行 它时,我得到上面的错误。
我通过更改python的版本解决了它。
从python3.7
到python3.6
我重新安装了相同版本的 Python (3.7.7)。我之前更改了我的 OpenSSL 版本,Python 需要重新安装它喜欢的版本。
我正在尝试从 cmd 启动 python 代码。我使用 python 3.7 和 Anaconda。我最初有一个 DLL 问题。根据论坛中的一些答案,我在 Windows OS 上的环境变量中插入了路径“C:\Users\andre\Anaconda3\envs\py37\Library\bin”。之后我遇到了以下错误:
Traceback (most recent call last):
File "C:\Users\andre\Documents\NetBeansProjects\Aladin_demo\py\get_class.py", line 8, in <module>
import gensim
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\gensim\__init__.py", line 5, in <module>
from gensim import parsing, corpora, matutils, interfaces, models, similarities, summarization, utils # noqa:F401
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\gensim\parsing\__init__.py", line 4, in <module>
from .preprocessing import (remove_stopwords, strip_punctuation, strip_punctuation2, # noqa:F401
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\gensim\parsing\preprocessing.py", line 42, in <module>
from gensim import utils
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\gensim\utils.py", line 45, in <module>
from smart_open import open
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\smart_open\__init__.py", line 28, in <module>
from .smart_open_lib import open, smart_open, register_compressor
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\smart_open\smart_open_lib.py", line 40, in <module>
import boto3
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\boto3\__init__.py", line 16, in <module>
from boto3.session import Session
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\boto3\session.py", line 17, in <module>
import botocore.session
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\botocore\session.py", line 30, in <module>
import botocore.credentials
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\botocore\credentials.py", line 34, in <module>
from botocore.config import Config
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\botocore\config.py", line 16, in <module>
from botocore.endpoint import DEFAULT_TIMEOUT, MAX_POOL_CONNECTIONS
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\botocore\endpoint.py", line 22, in <module>
from botocore.awsrequest import create_request_object
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\botocore\awsrequest.py", line 26, in <module>
import botocore.utils
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\botocore\utils.py", line 31, in <module>
import botocore.httpsession
File "C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\botocore\httpsession.py", line 7, in <module>
from urllib3.util.ssl_ import (
ImportError: cannot import name 'ssl' from 'urllib3.util.ssl_' (C:\Users\andre\Anaconda3\envs\py37\lib\site-packages\urllib3\util\ssl_.py)
当我在我的 Jupyter Notebook 中 运行 我的脚本时,我没有看到这个错误消息,但是当我在命令行上 运行 它时,我得到上面的错误。
我通过更改python的版本解决了它。
从python3.7
到python3.6
我重新安装了相同版本的 Python (3.7.7)。我之前更改了我的 OpenSSL 版本,Python 需要重新安装它喜欢的版本。