【发布时间】:2012-01-02 21:19:21
【问题描述】:
使用-Python 2.5 操作系统-Windows Vista 当我尝试使用
安装 Selenium 2.13 时出现错误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.py 文件是愚蠢的?新手,请多多包涵。按照给定的教程here。
在上面的教程中我不明白如何做到这一点:“将文件 selenium.py 添加到你的测试路径”
【问题讨论】: