Reputation: 1230
I am using:
There was an error when I tried to install Selenium 2.13 using
pip install -U Selenium
Output:
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...
So I downloaded the Selenium 2.13 package manually and copied the selenium.py file into c:/python25/lib/. However, when I try to import webdriver from within Python it gives me the following error:
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
Is there a problem with the Selenium install or is there something wrong that I am doing? Maybe copying just the selenium.py file is stupid?
I followed the tutorial given here.
In the above tutorial, how can I do the following?
"Add to your test’s path the file selenium.py"
Upvotes: 3
Views: 14743
Reputation: 9474
That installation manual seems a bit awkward to me. First, remove all files (try pip uninstall Selenium
, or if that doesn't work just remove the selenium
folder from your site-packages
folder). Also, delete the single selenium.py
file you copied.
Then, try again by running pip install -U selenium
. If you can then open your Python prompt and do the following without errors, you're good.
from selenium import webdriver
Note that you'll also need the Selenium server, installing it as follows:
java -jar selenium-server-standalone-2.13.0.jar
If all this doesn't work, clean your site-packages as before, and just download and install the files found on the Python package index. Once extracted, open a command prompt where you extracted the files and run python setup.py install
. Then, try to import selenium from the command prompt again as specified above.
Upvotes: 3
Reputation: 14080
Apparently Selenium 2.13 has a requirement of Python 2.6, given the syntax error (dependency: 'with').
You have an option to possibly install an earlier version of Selenium or, probably better, upgrade to Python 2.6 on your Windows machine.
Upvotes: 3