rsg*_*mon 5 python intellisense python-import visual-studio
该问题的示例。
档案结构
foo_folder
|
bar_module.py
| |___foo_func
| |____init___
python application folder
|___python_solution.sln, .proj ...
|___python_application.py
Run Code Online (Sandbox Code Playgroud)
bar_module.py:
def foo_func():
return 3.14
Run Code Online (Sandbox Code Playgroud)
python_application.py
from clients.reddit import foo_module
if __name__ == '__main__':
print(foo_module.foo_func())
Run Code Online (Sandbox Code Playgroud)
我有一个项目和一个.py文件的解决方案。该项目中的文件将模块导入到项目外部。现在在PowerShell中可以正常工作。但是在Visual Studio中却没有。这些是问题:
出现导入错误时,无法从Visual Studio运行此代码。
Intellisense不起作用。当我在python_application.py中工作时,没有intellisensefor bar_module。
现在我意识到我可以添加bar_module.py到项目中,但这会生成我不想要的本地副本。我需要更改什么以便可以从Visual Studio运行此代码并使Intellisense工作?