admin管理员组文章数量:1399119
In VS Code I have a little python (Python 3.11.9) module I'm building beside my main code. The module works fine and runs without issue. I've installed it in edit mode via pip install -e .
Still Pylance cannot resolve my module's imports in any file inside the module.
Import "my_cool_module.utils.logging_utils" could not be resolved
# my_cool_module.main.py
from my_cool_module.core.enhancer import AwesomeEnhancer
from my_cool_module.utils.logging_utils import configure_logging
def main()
pass
# More cool code
I've setup the __init__.py
in every directory and the follow the same pattern as the one below:
# my_cool_module.utils.__init__.py
from my_cool_module.utils.logging_utils import configure_logging # This import also cannot be resolved
__all__ = ['configure_logging']
This occurs in any file in the module that is importing other parts, the __init__.py
files should all be configured and it runs without issue.
.venv
Other Code Files <- We can import and use MyCoolModule without issue
My Cool Module
┣ ...other module code
┣ utils
┃ ┣ logging_utils.py
┃ ┗ __init__.py
┣ main.py
┣ pyproject.toml
┣ Readme.md
┣ setup.py
┗ __init__.py
I've verified my setup.py, I've created a pyproject.toml file to see if that was the issue. I've created a .env
file in my main directory with to manually add my workspace to the project path,
# .env
PYTHONPATH=${workspaceFolder}
I've also added the following settings to my .code-workspace
file
// MyProject.code-workspace
"settings":{
"python.autoComplete.extraPaths": [
"${workspaceFolder}",
"${workspaceFolder}/my_cool_module"
],
"python.analysis.extraPaths": [
"${workspaceFolder}",
"${workspaceFolder}/my_cool_module"
]
}
Still it seems that Pylance can't resolve the imports inside the module itself and I'd like to get that fixed.
本文标签: pythonPylance Local Installed Module Cannot Resolve Imports Inside PackageStack Overflow
版权声明:本文标题:python - Pylance Local Installed Module Cannot Resolve Imports Inside Package - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744191327a2594530.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论