[英]Python Splinter Library ImportError: cannot import name Browser
[英]Splinter: ImportError: cannot import name Browser
我是Splinter的新手,但我已經使用python幾次。 因此,我希望使用splinter使網站自動化。 但是執行它時出現“ ImportError:無法導入名稱瀏覽器”錯誤。
這是我的代碼。
from splinter import Browser
browser = Browser()
browser.visit('http://google.com')
browser.fill('q', 'splinter - python acceptance testing for web applications')
browser.find_by_name('btnG').click()
if browser.is_text_present('splinter.readthedocs.org'):
print "Yes, the official website was found!"
else:
print "No, it wasn't found... We need to improve our SEO techniques"
browser.quit()
在終端,這就是我得到的。
Traceback (most recent call last):
File "splinter.py", line 3, in <module>
from splinter import Browser
File "/var/www/project/splinter.py", line 3, in <module>
from splinter import Browser
ImportError: cannot import name Browser
如何運行該程序而不會出現任何錯誤? 我已經提到了解決類似問題的解決方案,例如刪除splinter.pyc,但這對我沒有幫助。
您有一個名為splinter.py
的本地文件,該文件遮蓋了庫的splinter
如從追溯中可以看到的那樣-
追溯(最近一次通話):
文件“ splinter.py” ,第3行,在
從碎片導入瀏覽器
重命名該文件,您不應以遮蓋/屏蔽庫的方式命名您的python文件或軟件包。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.