如何设置 Visual Studio 以尊重 PYTHONPATH 中的文件夹? [英] How to setup Visual Studio to respect folders in the PYTHONPATH?

查看:39
本文介绍了如何设置 Visual Studio 以尊重 PYTHONPATH 中的文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Visual Studio python 项目,我想使用 IntelliSense 来帮助我处理我添加到用户帐户 PYTHONPATH 的文件夹中的文件.在 iPython 中,我可以毫无问题地为此文件夹使用制表符补全.但是,在 VisualStudio 中,它一直告诉我我尝试包含的模块可能缺少 IntelliSense.

I have a Visual Studio python project and I would like to use IntelliSense to help me when working with files from a folder I added to the User-Account PYTHONPATH. In iPython I can use tab completion for this folder without issues. However, in VisualStudio it keeps telling me that IntelliSense may be missing for the module I try to include.

是否需要为 Visual Studio 设置任何设置以包含添加到 PYTHONPATH 的那些文件夹?

Are there any settings I have to set for Visual Studio to include those folders added to PYTHONPATH?

  • Visual Studio 2017
  • 蟒蛇 4.3.0
  • Windows 10

推荐答案

有一个设置在:Tools >选项 >Python 工具 >忽略系统范围的python路径.

虽然这对我来说似乎没有影响,但我认为这是我们都想做的选择.

Although this appears to have no effect for me, I think this is the option which would do what we both want.

使用 Visual Studio ipython 终端时

When using a visual studio ipython terminal

import os

print(os.environ['PYTHONPATH'])

出现一个关键错误,而在 VS 之外使用普通的 ipython 终端,路径被正确打印.

A key error is raised, while with a normal ipython terminal outside of VS, the path is correctly printed.

这篇关于如何设置 Visual Studio 以尊重 PYTHONPATH 中的文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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