编译python为cython(赋值前引用的局部变量'webdriver')
Compile python to cython (local variable 'webdriver' referenced before assignment)
我在 mac os 中将 python 编译为 cython 并收到此错误
warning: tag.py:404:4: Unreachable code
Error compiling Cython file:
------------------------------------------------------------
...
print(event)
window.close()
print('logging to account')
sleep(randint(2, 3))
chromedriver_path = './chromedriver'
webdriver = webdriver.Chrome(executable_path=chromedriver_path)
^
------------------------------------------------------------
tag.py:153:17: local variable 'webdriver' referenced before assignment
我认为错误属于这些行
chromedriver_path = './chromedriver'
webdriver = webdriver.Chrome(executable_path=chromedriver_path)
webdriver.minimize_window()
Selenim Python 绑定中没有方法 minimize_window()
:
删除那个 .
相反,我认为你想要最大化 :
driver.maximize_window()
不要将 webdriver
分配给 webdriver
改为这样做:
driver = webdriver.Chrome(r'C:\chromedriver.exe')
driver.maximize_window()
进口:
from selenium import webdriver
我在 mac os 中将 python 编译为 cython 并收到此错误
warning: tag.py:404:4: Unreachable code
Error compiling Cython file:
------------------------------------------------------------
...
print(event)
window.close()
print('logging to account')
sleep(randint(2, 3))
chromedriver_path = './chromedriver'
webdriver = webdriver.Chrome(executable_path=chromedriver_path)
^
------------------------------------------------------------
tag.py:153:17: local variable 'webdriver' referenced before assignment
我认为错误属于这些行
chromedriver_path = './chromedriver'
webdriver = webdriver.Chrome(executable_path=chromedriver_path)
webdriver.minimize_window()
Selenim Python 绑定中没有方法 minimize_window()
:
删除那个 .
相反,我认为你想要最大化 :
driver.maximize_window()
不要将 webdriver
分配给 webdriver
改为这样做:
driver = webdriver.Chrome(r'C:\chromedriver.exe')
driver.maximize_window()
进口:
from selenium import webdriver