8

I am using the Anaconda python distribution and would like to use the selenium package. Unfortunately the distribution does not have selenium included in it so I installed it using the recommended:

pip install -U selenium

the distribution FAQ say this should work fine but when I try to use it I get python telling me it does not know anything about this package.

i.e.

>>> import selenium
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named selenium

I checked and the /usr/local/lib/python2.7/dist-packages directory does have selenium within it. How do I point my python distribution to this so I can use the package?

G_T
  • 1,555
  • 1
  • 18
  • 34
  • 1
    The reason this is happening might be because your Anaconda is pointing to a different python path whereas you are installing the modules in a different python path. That can only be the reason as far as I see, because I just did the same process and it easily imports the selenium package. – Arpit Goyal May 26 '15 at 05:54
  • conda install -c https://conda.anaconda.org/metaperl selenium – Rasmi Ranjan Nayak Mar 27 '16 at 07:19

3 Answers3

15

Following the advice of a comment in this question I installed Selenium using the pip installed with the distribution.

~/anaconda/bin/pip install -U selenium

I did not know about this before but it seems to have worked.

Community
  • 1
  • 1
G_T
  • 1,555
  • 1
  • 18
  • 34
  • For Windows users, this also works if you run 'pip install -U selenium' inside the 'C:\Users\yourname\Anaconda3' directory with command prompt / power shell. – Matt Aug 12 '17 at 10:12
2

Following works for me:

conda install -c conda-forge selenium

Please check the Selenium page in Anaconda website for details.

Deqing
  • 14,098
  • 15
  • 84
  • 131
1

Try:

conda install -c metaperl selenium=2.40.0
Bono
  • 4,757
  • 6
  • 48
  • 77
Gerry Laureys
  • 301
  • 2
  • 3
  • 2
    While this code may answer the question, it would be better to include some context, explaining how it works and when to use it. Code-only answers are not useful in the long run. – Bono May 05 '16 at 18:10
  • This tried to force me to downgrade python 3.7 to 2.7, so be careful! – dopexxx Sep 25 '18 at 15:34