最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Import incorrectly identified by PyDev in VSCode as unresolved - Stack Overflow

programmeradmin2浏览0评论

To import the colorama module, I'm using import colorama.

When doing so into any .py file within my project (tested within multiple directories as well, including root), vscode underlines the 'colorama' keyword in red, stating Unresolved Import: colorama PyDev(6).

It seems to only be the colorama module, and not any of the other modules I've installed and imported (datetime, os, pygame, random, etc.).

This issue recently started after I created an __init__.py file within one of my directories so that I could import modules from there.

Directory structure:

Project Folder
├── venv
├── src
│   ├── __init__.py
│   ├── colorama_test2.py
└── colorama_test1.py

Import statements for colorama fail in both colorama_test files.

I'm using a venv. I've installed colorama into the venv via:

PS ...\Project Folder> pip install colorama
Requirement already satisfied: colorama in ...\Project Folder\venv\lib\site-packages (0.4.6)

Copilot is still convinced that the colorama module is not installed via pip. Just for kicks, I installed colorama to my global environment as well, but no luck.

I've also confirmed that the python interpreter that vscode is configured to use is set to the venv interpreter:

All vscode's linting settings appear to be default. I don't understand the different linting setting options to modify them with confidence. I did try enabling linting with Mypy and Flake8, but with no change in symptoms.

I've used the Python: Clear cache and reload window option. Again, no change to symptoms.

Reviewed vscode pylint reports module win32event as unresolved import when module is installed which indicates that due to pylint's limitations, it's unable to inspect certain files. However, per my editor's settings, pylint is turned off right now, so I don't suspect this is the issue.

To import the colorama module, I'm using import colorama.

When doing so into any .py file within my project (tested within multiple directories as well, including root), vscode underlines the 'colorama' keyword in red, stating Unresolved Import: colorama PyDev(6).

It seems to only be the colorama module, and not any of the other modules I've installed and imported (datetime, os, pygame, random, etc.).

This issue recently started after I created an __init__.py file within one of my directories so that I could import modules from there.

Directory structure:

Project Folder
├── venv
├── src
│   ├── __init__.py
│   ├── colorama_test2.py
└── colorama_test1.py

Import statements for colorama fail in both colorama_test files.

I'm using a venv. I've installed colorama into the venv via:

PS ...\Project Folder> pip install colorama
Requirement already satisfied: colorama in ...\Project Folder\venv\lib\site-packages (0.4.6)

Copilot is still convinced that the colorama module is not installed via pip. Just for kicks, I installed colorama to my global environment as well, but no luck.

I've also confirmed that the python interpreter that vscode is configured to use is set to the venv interpreter:

All vscode's linting settings appear to be default. I don't understand the different linting setting options to modify them with confidence. I did try enabling linting with Mypy and Flake8, but with no change in symptoms.

I've used the Python: Clear cache and reload window option. Again, no change to symptoms.

Reviewed vscode pylint reports module win32event as unresolved import when module is installed which indicates that due to pylint's limitations, it's unable to inspect certain files. However, per my editor's settings, pylint is turned off right now, so I don't suspect this is the issue.

Share Improve this question asked Jan 20 at 18:48 Asher CreechAsher Creech 212 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 0

Unresolved import issues with pydev and eclipse helped me find a resolution to this issue.

This was resolved by vscode > ctrl+shift+p > PyDev: Clear Caches.

发布评论

评论列表(0)

  1. 暂无评论