首页 > 解决方案 > VS Code 不使用 Python 执行 Python 代码

问题描述

尝试在 VS Code 中执行一些 Python 代码时,我收到以下错误消息:

from: can't read /var/mail/selenium.webdriver.common.keys
from: can't read /var/mail/selenium.webdriver.common.by
from: can't read /var/mail/selenium.webdriver.support.ui
from: can't read /var/mail/selenium.webdriver.support.ui
from: can't read /var/mail/selenium.webdriver.support

我认为这可能是因为它没有作为 Python 代码执行,但我对这一切都很陌生,我似乎无法纠正这个问题。奇怪的是,这段代码几周前我写的时候就可以工作了,但我不确定从现在到那时发生了什么。

我尝试将 VS Code 中的解释器设置为所有可用选项,并且我阅读了另一篇文章,该文章建议将以下行添加到代码顶部...

#!/usr/bin/env python

...但这也不起作用。如果有人能指出我正确的方向,我将不胜感激。

谢谢

标签: python

解决方案


我建议在带有命令的终端中运行 python in vs code。python name_of_the_file.py 。但不要忘记 cd 进入正确的目录或使用正确的虚拟环境。


推荐阅读