Don*_*ing 15 python django visual-studio-code
我的Visual Studio Code的Intellisense无法正常工作.每次我尝试使用它时Ctrl + Shift,它只显示加载消息.我正在使用Python(使用Django)并已安装ms-python.python.我也有Djaneiro.它仍然无法正常工作.
这里似乎有什么问题?
首先,如果您在项目中安装了 virtualenv,请从那里运行 vscode。然后在你的 vscode 设置中,我的意思是 settings.json,你可以按照我的配置或跟踪你有问题的地方。大多数情况下,这个问题源于在 pythonPath 设置中放置了不正确的路径
{
"python.pythonPath": "${workspaceFolder}/env/bin/python3",
"editor.formatOnSave": true,
"python.linting.pep8Enabled": true,
"python.linting.pylintPath": "pylint",
"python.linting.pylintArgs": ["--load-plugins", "pylint_django"],
"python.linting.pylintEnabled": true,
"python.linting.pep8Args": ["--ignore=E501"],
"files.exclude": {
"**/*.pyc": true
}
}
Run Code Online (Sandbox Code Playgroud)
更新:
如果你想有Vscode的精心配置,我个人用于开发我的Django和阵营就可以一览无余Web应用此。
安装Pylance插件导致 Vscode Intellisense 停止。
上停用Pylance并使得Default Microsoft Python extension沿着Visual Studio IntelliCode(Microsoft)和回复到Jedi server(由Vscode提示),重新启动智能感知检测。
小智 7
就我而言,有效的是在 vscode 上重新安装 python 扩展,它会自动安装pylance。
然后我只需按键盘上的“ctrl + ,”即可进入 vscode 设置,输入:pylance。
单击编辑setting.json并将“python.languageServer”更改为默认值
},
"terminal.integrated.sendKeybindingsToShell": true,
"python.defaultInterpreterPath": "C:source\\env\\Scripts\\python.exe",
"python.disableInstallationCheck": true,
"terminal.integrated.defaultProfile.windows": "Command Prompt",
**"python.languageServer": "Default"**,
"python.analysis.completeFunctionParens": true,
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"python.autoComplete.addBrackets": true,
"diffEditor.ignoreTrimWhitespace": false
Run Code Online (Sandbox Code Playgroud)
我希望这对你也有用,否则你可以尝试重新安装 intellicode 和 python 扩展,然后重新启动你的 vscode。
希望这个对你有帮助 :)
这可能是由多种原因引起的,其中一些原因如下。
1)VS代码中的Python可执行路径不正确
Solution: Configure the path to the python executable in the settings.json
Remember to re start VS Code once done.
Run Code Online (Sandbox Code Playgroud)
2)自定义模块位于非标准位置
Solution: Configure the settings.json to include this custom location for autocompletion to work
An exmample settings.json (for Linux) used to add a customModule from workspaceFolder
{
"python.pythonPath": "/usr/bin/python",
"python.autoComplete.extraPaths": [
"${workspaceFolder}/customModule"
]
}
Remember to re start VS Code once done.
Run Code Online (Sandbox Code Playgroud)
3)VS Code未从活动虚拟环境中启动
The path to the custom modules is set when a virtual environment is activated.
Solution: Launch VS Code from a Terminal/Command window with the correct virtual environment activated
Run Code Online (Sandbox Code Playgroud)
小智 6
我改变改变:jedi true 2 false,或flase 2 true,当重新加载VSCode时,没关系。
我的设置:
{
"editor.fontSize": 16,
"explorer.confirmDragAndDrop": false,
"extensions.autoUpdate": false,
"workbench.colorTheme": "Default Dark+",
"editor.fontFamily": "Consolas, Dengxian",
"workbench.sideBar.location": "left",
"workbench.startupEditor": "newUntitledFile",
"workbench.iconTheme": "material-icon-theme",
"python.pythonPath": "d:\\Source\\Django\\Scripts\\python.exe",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"git.ignoreLimitWarning": true,
"python.jediEnabled": true,
"python.autoComplete.extraPaths": [
"d:\\Source\\Django\\",
],
"python.autoComplete.addBrackets": true
}
Run Code Online (Sandbox Code Playgroud)
对我来说,Intellisense 在处理 Python 文件时会停止随机工作。
我只是保存我的文件,关闭文件选项卡,然后我重新打开并再次工作。
有时这不起作用,所以我只是重新启动 VS 代码,然后 Intellisense 重新上线。
| 归档时间: |
|
| 查看次数: |
16318 次 |
| 最近记录: |