如何使用anaconda3在Visual Studio Code中为python启用intellisense? [英] How to enable intellisense for python in Visual Studio Code with anaconda3?

查看:177
本文介绍了如何使用anaconda3在Visual Studio Code中为python启用intellisense?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Visual Studio Community几个月了,但是缓慢和基于项目的界面并不符合我的喜好,并且看到Visual Studio Code具有python扩展后,我决定再次尝试Code. /p>

代码存在两个问题,如果可能的话,我会将其提升为我的主编辑器.

首先是智能感知.我已经下载了代码的 python 扩展,它可以提供智能感知功能.但是,在核心python软件包(如数学")之外,intellisense无法正常工作.我已经尝试按照链接中的描述设置额外的环境变量,但是那也不起作用.

在此之后,我重新创建了anaconda环境,以防万一.每个anaconda环境基本上都作为独立的python安装进行操作,并在Lib/site-packages下具有"scipy"等模块,以便能够正确引用它们.

您可能会猜到,VS Code的智能感知仍然无法正常工作.也许有一种方法可以像VS Community一样刷新其数据库,但我找不到它.

我的第二个问题是缺少针对python的自动缩进,这不是我6个月前首次安装Code时的情况.这个问题是在2-3个月前提出的,我希望现在可以解决,但显然不是.互联网上也没有新的记载.

如何使VS Code与python一起正常工作?

解决方案

我已经在Windows 10 OS上安装了python 3.6.5和Django 2.0.4.

在vs代码中打开命令面板( Ctrl + Shift + p ).

选择 Python:选择解释器

关闭您的vs代码,然后尝试.如果仍然无法正常工作.通过更改为再试一次:-

Python:构建工作区符号,然后重新打开vs代码.这就是我所做的,并启用了智能功能.

I've been using Visual Studio Community for a few months now, but the sluggishness and project-based interface is not to my liking and having seen that Visual Studio Code has a python extension, I decided to try Code again.

There are two problems with Code, that if possible to solve I'd promote it to my main editor.

First is intellisense. I have downloaded the python extension for Code, which promises intellisense. However, outside of the core python packages (like "math") intellisense is not working. I've tried to set up the extra environment variable as described in the link, but that didn't work either.

After this I re-crated an anaconda environment, just in case. Each anaconda environment basically operates as a separate python install and has the modules like "scipy" etc under Lib/site-packages to properly be able to reference them.

As you might guess, intellisense for VS Code still isn't working. Maybe there's a way to refresh its database like for VS Community but I couldn't find it.

My second issue is lack of auto-indentation for python, which wasn't the case when I first installed Code some 6 months ago. The issue was present 2-3 months ago, I hoped it was fixed by now but apparently not. There's nothing new written about it on the Internets either.

How do I get VS Code to work well for me with python?

解决方案

I have installed python 3.6.5 and Django 2.0.4 on windows 10 OS.

In vs code open command palette (Ctrl+Shift+p).

There select Python:Select Interpreter

Close your vs code and then try. If it still does not work. Try again by changing to:-

Python:Build Workspace symbols and re-open the vs code. That's all i did and got intelligence enabled.

这篇关于如何使用anaconda3在Visual Studio Code中为python启用intellisense?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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