问题
I have just downloaded Visual Studio Code and tried to run some Python code. However, when I try to import Seleinum I receive the following error:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
Erros:
module selenium
unresolved import 'selenium'Python(unresolved-import)
unresolved import 'selenium.webdriver.common.keys' Python(unresolved-import)
Any idea how to make it work?
回答1:
The links below address the issue you are having. Your workspace settings are improperly configured. By adding the PATH of the virtual environment library/packages to the workspace settings, settings.json, file will correct the issue.
An example of my configuration in Windows 10:
"python.pythonPath": "C:\\Users\\UserName\\python-virtual-environments\\env\\lib",
Pylint "unresolved import" error in visual studio code
https://code.visualstudio.com/docs/getstarted/settings#_settings-file-locations
来源:https://stackoverflow.com/questions/57490408/unresolved-import-selenium-in-python