"reportMissingImports" error even though code and import works fine in VSCode

283 views Asked by At

Small question but annoying. In VSCode, it is reporting a "reportMissingImports" error even though the import and the code is working fine. Here is the relevant portion.

import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.ssl_ import create_urllib3_context

...

context = create_urllib3_context(ciphers=":".join(custom_cipher_suite))

The line with import create_urllib3_context is being reported as an error but the code runs fine and executes the module as the last line shows. In the python interpreter it runs fine:

Python 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from requests.packages.urllib3.util.ssl_ import create_urllib3_context
>>> create_urllib3_context()
<ssl.SSLContext object at 0x7f6c22d2d340>

Any idea why this is? I would like to avoid ignoring the error as that will also avoid it for legitimate purposes.

EDIT: Here is a screenshot of the program and problem in VS Code:

enter image description here

Here is the output:

TLS_AES_256_GCM_SHA384
TLS_CHACHA20_POLY1305_SHA256
TLS_AES_128_GCM_SHA256
ECDHE-ECDSA-AES256-GCM-SHA384
ECDHE-RSA-AES256-GCM-SHA384
ECDHE-ECDSA-CHACHA20-POLY1305
ECDHE-RSA-CHACHA20-POLY1305
ECDHE-ECDSA-AES256-CCM8
ECDHE-ECDSA-AES256-CCM
ECDHE-ECDSA-ARIA256-GCM-SHA384
ECDHE-ARIA256-GCM-SHA384
ECDHE-ECDSA-AES128-GCM-SHA256
ECDHE-RSA-AES128-GCM-SHA256
ECDHE-ECDSA-AES128-CCM8
ECDHE-ECDSA-AES128-CCM
ECDHE-ECDSA-ARIA128-GCM-SHA256
ECDHE-ARIA128-GCM-SHA256
ECDHE-ECDSA-AES256-SHA384
ECDHE-RSA-AES256-SHA384
ECDHE-ECDSA-CAMELLIA256-SHA384
ECDHE-RSA-CAMELLIA256-SHA384
ECDHE-ECDSA-AES128-SHA256
ECDHE-RSA-AES128-SHA256
ECDHE-ECDSA-CAMELLIA128-SHA256
ECDHE-RSA-CAMELLIA128-SHA256
ECDHE-ECDSA-AES256-SHA
ECDHE-RSA-AES256-SHA
ECDHE-ECDSA-AES128-SHA
ECDHE-RSA-AES128-SHA
RSA-PSK-AES256-GCM-SHA384
DHE-PSK-AES256-GCM-SHA384
RSA-PSK-CHACHA20-POLY1305
DHE-PSK-CHACHA20-POLY1305
ECDHE-PSK-CHACHA20-POLY1305
DHE-PSK-AES256-CCM8
DHE-PSK-AES256-CCM
RSA-PSK-ARIA256-GCM-SHA384
DHE-PSK-ARIA256-GCM-SHA384
AES256-GCM-SHA384
AES256-CCM8
AES256-CCM
ARIA256-GCM-SHA384
PSK-AES256-GCM-SHA384
PSK-CHACHA20-POLY1305
PSK-AES256-CCM8
PSK-AES256-CCM
PSK-ARIA256-GCM-SHA384
RSA-PSK-AES128-GCM-SHA256
DHE-PSK-AES128-GCM-SHA256
DHE-PSK-AES128-CCM8
DHE-PSK-AES128-CCM
RSA-PSK-ARIA128-GCM-SHA256
DHE-PSK-ARIA128-GCM-SHA256
AES128-GCM-SHA256
AES128-CCM8
AES128-CCM
ARIA128-GCM-SHA256
PSK-AES128-GCM-SHA256
PSK-AES128-CCM8
PSK-AES128-CCM
PSK-ARIA128-GCM-SHA256
AES256-SHA256
CAMELLIA256-SHA256
AES128-SHA256
CAMELLIA128-SHA256
ECDHE-PSK-AES256-CBC-SHA384
ECDHE-PSK-AES256-CBC-SHA
SRP-DSS-AES-256-CBC-SHA
SRP-RSA-AES-256-CBC-SHA
SRP-AES-256-CBC-SHA
RSA-PSK-AES256-CBC-SHA384
DHE-PSK-AES256-CBC-SHA384
RSA-PSK-AES256-CBC-SHA
DHE-PSK-AES256-CBC-SHA
ECDHE-PSK-CAMELLIA256-SHA384
RSA-PSK-CAMELLIA256-SHA384
DHE-PSK-CAMELLIA256-SHA384
AES256-SHA
CAMELLIA256-SHA
PSK-AES256-CBC-SHA384
PSK-AES256-CBC-SHA
PSK-CAMELLIA256-SHA384
ECDHE-PSK-AES128-CBC-SHA256
ECDHE-PSK-AES128-CBC-SHA
SRP-DSS-AES-128-CBC-SHA
SRP-RSA-AES-128-CBC-SHA
SRP-AES-128-CBC-SHA
RSA-PSK-AES128-CBC-SHA256
DHE-PSK-AES128-CBC-SHA256
RSA-PSK-AES128-CBC-SHA
DHE-PSK-AES128-CBC-SHA
ECDHE-PSK-CAMELLIA128-SHA256
RSA-PSK-CAMELLIA128-SHA256
DHE-PSK-CAMELLIA128-SHA256
AES128-SHA
CAMELLIA128-SHA
PSK-AES128-CBC-SHA256
PSK-AES128-CBC-SHA
PSK-CAMELLIA128-SHA256
1

There are 1 answers

8
JialeDu On

The python version you use in the command line is Python 3.10.6. Select the same python interpreter in vscode(Ctrl+Shift+P --> Python: Select Interpreter) and the version will be displayed in the lower right corner.

enter image description here

In addition, the way to execute the script should be to use python extension.

enter image description here

If you want to rudely ignore the error, use the following setting:

    "python.analysis.diagnosticSeverityOverrides": {
        "reportMissingImports": "none",
    },