I\'m trying to write a script to check a website. It\'s the first time I\'m using selenium. I\'m trying to run the script on a OSX system. Although I checked in /Library/Pyt
I had a similar problem. It turned out that I had an alias defined for python like so:
alias python=/usr/bin/python3
Apparently virtualenv does not check or update your aliases.
So the solution for me was to remove the alias:
unalias python
Now when I run python, I get the one from the virtual environment. Problem solved.
Navigate to your scripts folder in Python directory (C:\Python27\Scripts) and open command line there (Hold shift and right click then select open command window here). Run pip install -U selenium
If you don't have pip installed, go ahead and install pip first
For python3, on a Mac you must use pip3 to install selenium.
sudo pip3 install selenium
If pip isn’t already installed, then first try to bootstrap it from the standard library:
sudo python -m ensurepip --default-pip
Ensure pip, setuptools, and wheel are up to date
sudo python -m pip install --upgrade pip setuptools wheel
Now Install Selenium
sudo pip install selenium
Now run your runner.
Hope this helps. Happy Coding !!
While pip install might work. Please check the project structure and see if there is no virtual environment already (It is a good practice to have one) created in the project. If there is, activate it with source <name_of_virtual_env>/bin/activate
(for MacOS) and venv\Scripts\Activate.ps1
(for Windows powershell) or venv\Scripts\activate.bat
(for Windows cmd). then pip install selenium into the environment.
If it isn't,
check if you have a virtual environment with virtualenv --version
If it displays an error, install it with pip install virtualenv
then create a virtual environment with
virtualenv <name_of_virtual_env>
(Both Windows and MacOS)or
python -m venv <name_of_virtual_env>
(Windows Only)
then activate the virtual environment
with
source <name_of_virtual_env>/bin/activate
(for MacOS) and
venv\Scripts\Activate.ps1
(for Windows powershell) or
venv\Scripts\activate.bat
(for Windows cmd).
then install selenium with pip install -U selenium (it will install the latest version).
If it doesn't display an error, just create a virtual environment in the project, activate it and install selenium inside of it.
I ran into the same problem with pycharm where my modules wouldn't import after installing them on ubuntu with pip.
If you go File-> Settings -> Project > Python Interpreter
You can click the '+' on the right hand side and import modules into the interpreter.
Not sure if that's your issue but hope this helps.