python-for-data-and-media-communication-gitbook icon indicating copy to clipboard operation
python-for-data-and-media-communication-gitbook copied to clipboard

Chromedriver is not in the Path

Open MindyZHAOMinzhu opened this issue 5 years ago • 11 comments

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. 屏幕快照 2019-07-29 下午8 53 35 屏幕快照 2019-07-29 下午8 45 54

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.

MindyZHAOMinzhu avatar Jul 29 '19 12:07 MindyZHAOMinzhu

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)

hupili avatar Jul 29 '19 13:07 hupili

!echo $PATH
屏幕快照 2019-07-29 下午10 58 08
!ls
屏幕快照 2019-07-29 下午10 58 29
! pwd
屏幕快照 2019-07-29 下午10 58 37

MindyZHAOMinzhu avatar Jul 29 '19 15:07 MindyZHAOMinzhu

please execute those in the note book where error arose.

hupili avatar Jul 29 '19 15:07 hupili

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

屏幕快照 2019-07-30 上午8 27 32

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.

屏幕快照 2019-07-30 上午8 26 17

Try it again and you will find it works now.

MindyZHAOMinzhu avatar Jul 30 '19 00:07 MindyZHAOMinzhu

@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).

hupili avatar Jul 30 '19 08:07 hupili

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.

hupili avatar Jul 30 '19 08:07 hupili

Can I use sys.path.append(your_path_string_here) in my code in my jupyternotebook? Or use it in the terminal?

MindyZHAOMinzhu avatar Jul 30 '19 22:07 MindyZHAOMinzhu

I try to use terminal to get venv, but it seems I get the same path. 屏幕快照 2019-07-31 上午6 39 50

MindyZHAOMinzhu avatar Jul 30 '19 22:07 MindyZHAOMinzhu

sys.path.append(your_path_string_here) is to use in the Jupyter notebook.

hupili avatar Aug 04 '19 08:08 hupili

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.👇 屏幕快照 2019-08-06 下午4 28 45

MindyZHAOMinzhu avatar Aug 06 '19 08:08 MindyZHAOMinzhu

@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.

hupili avatar Aug 11 '19 12:08 hupili