由于无法导入,我无法调试代码或运行Python控制台
ssl
. 我在使用我创建的两个Anaconda虚拟环境时会出现这种行为。
例如,当我尝试调试使用
boto3
C:\home\miniconda\envs\scw\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.4\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 57111 --file C:/home/git/onvif_interact/onvif_interact/notifications.py --config C:\home\data\pullpoint\camera_desk.ini
pydev debugger: process 22816 is connecting
Connected to pydev debugger (build 183.5429.31)
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.4\helpers\pydev\pydevd.py", line 1741, in <module>
main()
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.4\helpers\pydev\pydevd.py", line 1735, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.4\helpers\pydev\pydevd.py", line 1135, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.4\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/home/git/onvif_interact/onvif_interact/notifications.py", line 3, in <module>
import boto3
File "C:\home\miniconda\envs\scw\lib\site-packages\boto3\__init__.py", line 16, in <module>
from boto3.session import Session
File "C:\home\miniconda\envs\scw\lib\site-packages\boto3\session.py", line 17, in <module>
import botocore.session
File "C:\home\miniconda\envs\scw\lib\site-packages\botocore\session.py", line 30, in <module>
import botocore.credentials
File "C:\home\miniconda\envs\scw\lib\site-packages\botocore\credentials.py", line 42, in <module>
from botocore.utils import InstanceMetadataFetcher, parse_key_val_file
File "C:\home\miniconda\envs\scw\lib\site-packages\botocore\utils.py", line 31, in <module>
import botocore.httpsession
File "C:\home\miniconda\envs\scw\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:\home\miniconda\envs\scw\lib\site-packages\urllib3\util\ssl_.py)
Process finished with exit code 1
当我尝试运行Python控制台时,会出现类似的错误:
C:\home\miniconda\envs\scw\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.4\helpers\pydev\pydevconsole.py" --mode=client --port=57152
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.4\helpers\pydev\pydevconsole.py", line 5, in <module>
from _pydev_comm.rpc import make_rpc_client, start_rpc_server, start_rpc_server_and_make_client
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.4\helpers\pydev\_pydev_comm\rpc.py", line 4, in <module>
from _pydev_comm.server import TSingleThreadedServer
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.4\helpers\pydev\_pydev_comm\server.py", line 4, in <module>
from _shaded_thriftpy.server import TServer
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.4\helpers\third_party\thriftpy\_shaded_thriftpy\server.py", line 9, in <module>
from _shaded_thriftpy.transport import (
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.4\helpers\third_party\thriftpy\_shaded_thriftpy\transport\__init__.py", line 57, in <module>
from .sslsocket import TSSLSocket, TSSLServerSocket # noqa
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.4\helpers\third_party\thriftpy\_shaded_thriftpy\transport\sslsocket.py", line 7, in <module>
import ssl
File "C:\home\miniconda\envs\scw\lib\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified procedure could not be found.
Process finished with exit code 1
可能与此相关的是,我在PyCharm中创建了一个新的虚拟环境,当我尝试更新pip模块时,出现了以下与SSL相关的错误:
Collecting pip==19.0.1
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
Could not find a version that satisfies the requirement pip==19.0.1 (from versions: )
No matching distribution found for pip==19.0.1
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.