4

Newbeeここに。何故この問題が起きたのか、どうやって解決するのか、どうか説明してください。ImportError:sys.meta_path isなし、Pythonがシャットダウンする可能性があります

エラー:使用

"C:\Program Files (x86)\Python36-32\python.exe" C:/Users/Vivek-Pc/PycharmProjects/tryOutSeries/searchTryout2.py Exception ignored in: > Traceback (most recent call last): File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 173, in del File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 149, in stop File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.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

コード:

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

driver_path = "c:\Program Files (x86)\Python36-32\Lib\site-packages\selenium\webdriver\chrome\chromedriver" 
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() 

環境情報:

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

答えて

6

Python 3.6、Selenium 3.0.2、ChromeDriver 2.27を使用して同じエラーを再現しました。

問題がstop the chromedriver serviceにしようとwebdriverをPythonのセレンを使用して、明示的にドライバを閉じるのいずれかのときとき、またはスクリプトの実行が簡単に終了する(と__del__メソッドが実行されるようになる)場合に発生することが表示されます。

は、Python /セレンgithubの問題追跡に問題を報告:

を回避策:

私はdriver.quit()代わりのdriver.close()を使用して、問題を回避するのに役立ちますことを見出しました。

+0

ありがとうalecxe! – Vivek22

+0

あなたに知らせてください。 driver.quit()またはdriver.close()を使用しなくても、同じエラーが発生します。 "C:¥Program Files(x86)¥Python36-32¥python.exe" D:/iqz/my-works/automation-practice/practice/selenium-tryout/firefoxSearch.py​​ ImportError:sys.meta_pathはNoneですが、 ................ Pythonがシャットダウンする可能性があります 終了コード0で終了したプロセス Vivek22

+0

コード使用:セレンインポートwebdriverから path1 = 'C:\ Program Files )\ Python36-32 \ Lib \ site-packages \ selenium \ webdriver \ edge \ MicrosoftWebDriver.exe ' ブラウザ= webdriver.Edge(パス1) browser.get( "https://www.google.com/") – Vivek22

関連する問題