Visual Studio 如何将 Python 模块添加到 Intellisense
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30605416/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio How to add Python module to Intellisense
提问by CompSci-PVT
How do I add a custom python module to the Visual Studio IntelliSense code completion tool?
如何将自定义 python 模块添加到 Visual Studio IntelliSense 代码完成工具?
Situation: I am working on a python module that references another module that I have saved in /myPython/foo.py.
情况:我正在处理一个 python 模块,该模块引用了我保存在 /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.
如果我开始键入 foo.someDef,我希望 IntelliSense 识别我正在访问该模块并建议代码完成。
采纳答案by CompSci-PVT
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.
Visual Studio 的 Intellisense 将在将自定义 Python 模块正确放置在 Python 目录中“Lib”文件夹下的“site-packages”文件夹中后识别它们。
For example: /Python27/Lib/site-packages/myPython
例如:/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.
在文件夹“myPython”内,放置一个名为“__init__.py”的纯文本文件。否则 Intellisense 将无法识别您的包裹。
You may also have to click the "Refresh DB" under the Python Environments tab.
您可能还需要单击 Python Environments 选项卡下的“Refresh DB”。
回答by Axel Arnold Bangert
Hello, this is the new ai enabled intellicode plugin for VS 2017 (python). You can install it and test the result.
https://marketplace.visualstudio.com/items?itemName=VisualStudioExptTeam.VSIntelliCodeTurn intellisense database !OFF! by setting -> tools->options->python->experimental->!ON!
你好,这是 VS 2017 (python) 新的支持 AI 的智能代码插件。您可以安装它并测试结果。
https://marketplace.visualstudio.com/items?itemName=VisualStudioExptTeam.VSIntelliCode关闭智能感知数据库!关闭!通过设置->工具->选项->python->实验->!ON!
Now it works with the new ai-based intellicode.
There may be a short delay-time, which is ai-backend-communication-referred (https://prod.intellicode.vsengsaas.visualstudio.com/). But after a short time you get all intellicode informations - may be - perhaps it may last one day :) ). Repeat the dot several times if necessary.
可能会有很短的延迟时间,这是 ai-backend-communication-referred ( https://prod.intellicode.vsengsaas.visualstudio.com/)。但是在很短的时间之后你会得到所有的智能码信息——可能是——也许它可能会持续一天:))。如有必要,重复该点数次。
Best Axel Arnold Bangert - Herzogenrath 01.2019
最佳 Axel Arnold Bangert - Herzogenrath 01.2019