Import "psycopg2" could not be resolved from source Pylance

My app works locally, but when I deploy it in github codespace, it will return the following message (*I already add psycopg2 and pingouin in requirement.txt):

[{
“resource”: “/workspaces/ppm-automation-test/pages/Hello.py”,
“owner”: “generated_diagnostic_collection_name#0”,
“code”: {
“value”: “reportMissingModuleSource”,
“target”: {
“$mid”: 1,
“path”: “/microsoft/pyright/blob/main/docs/configuration.md”,
“scheme”: “https”,
“authority”: “github.com”,
“fragment”: “reportMissingModuleSource”
}
},
“severity”: 4,
“message”: “Import "psycopg2" could not be resolved from source”,
“source”: “Pylance”,
“startLineNumber”: 3,
“startColumn”: 8,
“endLineNumber”: 3,
“endColumn”: 16
}]

[{
“resource”: “/workspaces/ppm-automation-test/pages/Hello.py”,
“owner”: “generated_diagnostic_collection_name#0”,
“code”: {
“value”: “reportMissingImports”,
“target”: {
“$mid”: 1,
“path”: “/microsoft/pyright/blob/main/docs/configuration.md”,
“scheme”: “https”,
“authority”: “github.com”,
“fragment”: “reportMissingImports”
}
},
“severity”: 4,
“message”: “Import "pingouin" could not be resolved”,
“source”: “Pylance”,
“startLineNumber”: 6,
“startColumn”: 8,
“endLineNumber”: 6,
“endColumn”: 16
}]

Hi @Vika,

Thanks for sharing your question with the community! :balloon: Please update your debugging post to include a code snippet and a link to your app’s public GitHub repo – this will allow the community to help you find an answer as quickly as possible. In the meantime, this post will be tagged as needs-more-info.

requirements.txt

Hi @Caroline @Franky1, I changed ‘psycopg2’ to ‘psycopg2-binary’ in my requirements.txt and solved the problem. Thanks for your reply :smiley:

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.