Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

selenium - ImportError: sys.meta_path is None, Python is likely shutting down

Newbee here. Kindly explain why this issue happened and how to fix it.

Error:

"C:Program Files (x86)Python36-32python.exe" C:/Users/Vivek-Pc/PycharmProjects/tryOutSeries/searchTryout2.py Exception ignored in: > Traceback (most recent call last): File "C:Program Files (x86)Python36-32libsite-packagesseleniumwebdrivercommonservice.py", line 173, in del File "C:Program Files (x86)Python36-32libsite-packagesseleniumwebdrivercommonservice.py", line 149, in stop File "C:Program Files (x86)Python36-32libsite-packagesseleniumwebdrivercommonservice.py", line 120, in send_remote_shutdown_command ImportError: sys.meta_path is None, Python is likely shutting down Process finished with exit code 0

Code Used:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver_path = "c:Program Files (x86)Python36-32Libsite-packagesseleniumwebdriverchromechromedriver"
b_obj = webdriver.Chrome(driver_path)
b_obj.implicitly_wait(15)
b_obj.maximize_window()
b_obj.get('http://stackoverflow.com/')

search_box = b_obj.find_element_by_name('q')
search_box.clear()
search_box.send_keys("Selenium")
search_box.submit()
b_obj.close()

Environment Info:

Windows, Selenium, Python, Chrome (chromedriver.exe) & PyCharm

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I've reproduced the same error using Python 3.6, Selenium 3.0.2 and ChromeDriver 2.27 (everything latest at this point).

The problem appears to happen when the Python selenium webdriver tries to stop the chromedriver service either when you explicitly close the driver, or when the script execution simply ends (and the __del__ method gets to be executed).

Reported the issue to Python/Selenium github issue tracker:

Workaround:

I found that using driver.quit() instead of driver.close() helps to workaround the problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...