Visual Studio 代码:即使选择了 python v3,python 选择器也默认为版本 2 [英] visual studio code: python selector defaults to version 2 even when python v3 selected

查看:36
本文介绍了Visual Studio 代码:即使选择了 python v3,python 选择器也默认为版本 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使选择了 Python3 解释器,Visual Studio Code 也会运行 Python2.我按右上角的播放按钮运行代码.我已将工作站和用户设置 python.pythonpath 更改为C:\Program Files (x86)\Python37-32\python.exe",以防万一.我在我正在运行的文件和输出下面包含了一个屏幕截图:

任何人都可以解释为什么会这样以及我如何纠正它?

非常感谢

谢谢

解决方案

这是意料之中的.您需要创建一个虚拟环境,该环境被激活以使 python 命令指向除 PATH 具有的 python 之外的任何内容.>

Visual Studio Code runs Python2 even when Python3 interpreter is selected. I run the code by pressing the play button at the top right. I've changed the workstation and user settings python.pythonpath to "C:\Program Files (x86)\Python37-32\python.exe" just incase. I've included a screen capture below of the file im running and the output :

Can anyone shed any light on why this might be and how i can correct it?

Much appreciated

Thanks

解决方案

That's expected. You need to create a virtual environment that gets activated to make the python command point to something other than whatever your PATH has as python.

这篇关于Visual Studio 代码:即使选择了 python v3,python 选择器也默认为版本 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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