[英]Visual Studio Code don't find selenium
I created a virtualenv in python and then installed with all modules needed to my project.我在 python 中创建了一个 virtualenv,然后安装了我的项目所需的所有模块。
requests certifi beatifulsoap4 ...请求 certifi beatifulsoap4 ...
If i run the program in the integrated terminal in visual studio code, it works fine.如果我在 Visual Studio 代码的集成终端中运行该程序,它运行良好。 But If use de command "Run Code" - CTRL+Alt+N - in visual studio code I get the follow error
但是如果使用 de 命令“运行代码” - CTRL+Alt+N - 在 Visual Studio 代码中,我会收到以下错误
from selenium import webdriver
ImportError: No module named selenium
I already changed the python path to point to my virtualenv but problem persist.我已经将 python 路径更改为指向我的 virtualenv,但问题仍然存在。
{
"files.autoSave": "afterDelay",
"python.pythonPath": "env/bin/python3"
}
If i change my code to not use selenium, then the "Run Code" command works fine (eveen with others imports)如果我将代码更改为不使用 selenium,则“运行代码”命令可以正常工作(与其他导入一起使用)
I have the same problem, Selenium was installed but Visual Studio was not able to import it.我有同样的问题,Selenium 已安装,但 Visual Studio 无法导入它。 In Laymen's term:
用外行的话来说:
The thing is Selenium is installed but VS Code can't access it, and you need link both them.
问题是安装了 Selenium 但 VS Code 无法访问它,您需要将它们链接起来。
That's how I solved it.我就是这样解决的。
pip uninstall selenium
pip uninstall selenium
卸载 Seleniumpip install selenium
pip install selenium
在该虚拟环境中pip install selenium
pipfile
and pipfile.lok
) pipfile
和pipfile.lok
) 后,您将看到文件夹中包含一些文件pipenv install pylint --dev
pipenv install pylint --dev
将pipenv install pylint --dev
到您的虚拟环境中If you still get an error, open your command-line and install selenium on your PC.
如果仍然出现错误,请打开命令行并在 PC 上安装 selenium。 Previously we installed it only in our virtual environment.
以前我们只在我们的虚拟环境中安装它。
If you are using vscode with anaconda, re-installing selenium package thru anaconda prompt instead of cmd/vscode terminal might help.如果您在 anaconda 中使用 vscode,通过 anaconda 提示符而不是 cmd/vscode 终端重新安装 selenium 包可能会有所帮助。
I had installed bs4 & selenium thru cmd, but it was not able to import selenium in vscode.我已经通过 cmd 安装了 bs4 和 selenium,但它无法在 vscode 中导入 selenium。 (while importing bs4 was fine) I was using vscode with anaconda, so I tried to re-install selenium thru anaconda prompt.
(虽然导入 bs4 很好)我在 anaconda 中使用 vscode,所以我尝试通过 anaconda 提示重新安装 selenium。 After that, I was finally able to import selenium in vscode.
之后,我终于能够在vscode中导入selenium。
I don't have much knowledge about computer and softwares, so I don't know why this happened but anyways I resolved the problem using anaconda prompt.我对计算机和软件的了解不多,所以我不知道为什么会发生这种情况,但无论如何我使用 anaconda prompt 解决了问题。
hope it would be helpful for you :)希望对你有帮助:)
I ran into the same problem..what worked for me is instead of running the python file in VScode I tried some other interpreter and it worked....but before that you need to check whether selenium is actually present or not in your local machine..you can do this in using terminal(on Mac) open terminal.我遇到了同样的问题..对我有用的是而不是在 VScode 中运行 python 文件我尝试了一些其他解释器并且它起作用了......但在此之前你需要检查硒是否真的存在于你的本地机器..你可以使用终端(在 Mac 上)打开终端来做到这一点。 type python3 type import selenium
输入 python3 输入硒
if this runs without any kind of error then you are good to go如果这运行没有任何错误,那么你很高兴
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.