python-for-data-and-media-communication-gitbook
python-for-data-and-media-communication-gitbook copied to clipboard
Chromedriver is not in the Path
My environment
- Device/ Operating System: ios
- Python version: python3
- Which chapter of book?: chapter8
My question
It shows error message when I finish downloading chromedriver.
The minimum code (snippet) to reproduce the issue
Example:
from selenium import webdriver
browser = webdriver.Chrome()
I have tried to move chromedriver file into different places, but it did not work.
PATH issue is common.
Please use the following commands to verify whether you have the right path or not.
!echo $PATH
!ls
!pwd
Let's checkout the command output of the above three cells.
https://en.wikipedia.org/wiki/PATH_(variable)
!echo $PATH

!ls

! pwd

please execute those in the note book where error arose.
Thank you so much!!!!!! I get it. My solution is as followed, it may help others.
The first step ---- check the path
!echo $PATH
use this code in your terminal

The second step ---- Download suitable version of chromedriver
download the proper version of the chromedriver. At first, I download the newest version which was not suitable for my Chrome. You can check your Chrome version in the Help----About Google Chrome
The third step --- move your chromedriver
I download it in /Users/zhaoxiaozhao(my user name), so I move it into right place( /Library/Frameworks/Python.framework/Versions/3.7/bin). I check the path in the first step.

Try it again and you will find it works now.
@MindyZHAOMinzhu very good first quick solution!
Besides moving into the system default executable path, i.e. your currently highlighted one, you can also try to add the folder that contains chromedriver into the $PATH variable by sys.path.append(your_path_string_here)
.
btw, are you using Anaconda's Jupyter notebook?
I guess the issue will be surpressed if you use the virtual environment setup from this book.
Can I use sys.path.append(your_path_string_here)
in my code in my jupyternotebook? Or use it in the terminal?
I try to use terminal to get venv, but it seems I get the same path.
sys.path.append(your_path_string_here)
is to use in the Jupyter notebook.
Thank you a lot!! I got it. I tried the code: sys.path.append(your_path_string_here)
, and find it is useful.
There are more detais which about the solution. I write something useful I find online here which maybe help others who have the same question.👇
@MindyZHAOMinzhu
https://github.com/hupili/python-for-data-and-media-communication/blob/master/jupyter-notebook/Demo%20of%20PATH.ipynb
This demo can give you further information on the PATH variable.