使用Python2.5 操作系统Windows Vista 当我尝试使用
pip install -U Selenium
C:\Users\User>pip install -U Selenium
Downloading/unpacking Selenium
Downloading selenium-2.13.1.tar.gz (3.3Mb): 3.3Mb downloaded
Running setup.py egg_info for package Selenium
warning: no files found matching 'docs\api\py\index.rst'
c:\Python25\lib\distutils\dist.py:263: UserWarning: Unknown distribution option: 'src_root'
warnings.warn(msg)
Downloading/unpacking rdflib==3.1.0 (from Selenium)
Downloading rdflib-3.1.0.tar.gz (249Kb): 249Kb downloaded
Running setup.py egg_info for package rdflib
Installing collected packages: Selenium, rdflib
Found existing installation: selenium 2.13.1
Uninstalling selenium:
Successfully uninstalled selenium
Running setup.py install for Selenium
warning: no files found matching 'docs\api\py\index.rst'
c:\Python25\lib\distutils\dist.py:263: UserWarning: Unknown distribution option: 'src_root'
warnings.warn(msg)
c:\Python25\Lib\site-packages\selenium\webdriver\remote\webdriver.py:668: Warning: 'with' will become a reserved keyword in Python 2.6
File "c:\Python25\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 668 with open(filename, 'wb') as f:
^
SyntaxError: invalid syntax
Found existing installation: rdflib 3.1.0
Uninstalling rdflib:
Successfully uninstalled rdflib
Running setup.py install for rdflib
Successfully installed Selenium rdflib
Cleaning up...
所以手动下载了Selenium 2.13包,并将Selenium.py文件复制到c://python25/lib/。但是,当我尝试从python中导入webdriver时,它会给出以下错误:
C:\Users\User>python F:\Selenium\localtest2.py
Traceback (most recent call last):
File "F:\Selenium\localtest2.py", line 1, in <module>
from selenium import webdriver
ImportError: cannot import name webdriver
selenium安装是否有问题,或者我正在做什么错误的事情?也许仅仅复制selenium.py文件是愚蠢的?菜鸟,容忍我。遵循给定的教程appendix_installing_python_driver_client.html" rel="nofollow">here。
在上面的教程中,我不知道如何做到这一点:“将文件selenium.py添加到测试路径”
显然,Selenium 2.13对python2.6有要求,因为语法错误(依赖项:“with”)。
您可以选择在Windows机器上安装早期版本的Selenium,或者升级到Python 2.6。
那个安装手册对我来说有点尴尬。首先,删除所有文件(尝试
pip uninstall Selenium
,如果不起作用,只需从site-packages
文件夹中删除selenium
文件夹)。另外,删除复制的单个selenium.py
文件。然后,通过运行
pip install -U selenium
重试。如果随后可以打开python提示符,并在没有错误的情况下执行以下操作,那么就可以了。注意,您还需要Selenium server,安装如下:
如果所有这些都不起作用,请像以前一样清理站点包,然后下载并安装Python package index上的文件。提取后,打开一个命令提示符,在其中提取文件并运行
python setup.py install
。然后,按照上面的指定,再次尝试从命令提示符导入selenium。相关问题 更多 >
编程相关推荐