Visual Studio如何将Python模块添加到Intellisense [英] Visual Studio How to add Python module to Intellisense

查看:241
本文介绍了Visual Studio如何将Python模块添加到Intellisense的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将自定义python模块添加到Visual Studio IntelliSense代码完成工具中?

情况:我正在研究一个python模块,该模块引用了我保存在/myPython/foo.py中的另一个模块.

如果我开始键入foo.someDef,我希望IntelliSense能够识别出我正在访问该模块并建议代码完成.

解决方案

在将自定义Python模块正确放置在Python目录的"Lib"文件夹下的"site-packages"文件夹中之后,Visual Studio的Intellisense会识别它​​们./p>

例如: /Python27/Lib/site-packages/myPython

在文件夹"myPython"内,放置一个名为"__init__.py"的纯文本文件.否则,Intellisense将无法识别您的包裹.

您可能还需要单击"Python环境"标签下的刷新数据库".

How do I add a custom python module to the Visual Studio IntelliSense code completion tool?

Situation: I am working on a python module that references another module that I have saved in /myPython/foo.py.

If I start to type foo.someDef I would like IntelliSense to recognize I am accessing that module and suggest a code completion.

解决方案

Visual Studio's Intellisense will recognize custom Python modules after they have been properly placed in the "site-packages" folder under the "Lib" folder in Python's directory.

For example: /Python27/Lib/site-packages/myPython

Inside of the folder "myPython", put a plain text file called "__init__.py". Otherwise Intellisense will not recognize your package.

You may also have to click the "Refresh DB" under the Python Environments tab.

这篇关于Visual Studio如何将Python模块添加到Intellisense的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆