hupili / python-for-data-and-media-communication-gitbook

An open source book on Python tailed for communication students with zero background
117 stars 62 forks source link

Chromedriver is not in the Path #164

Open MindyZHAOMinzhu opened 5 years ago

MindyZHAOMinzhu commented 5 years ago

My environment

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.

hupili commented 5 years ago

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)

MindyZHAOMinzhu commented 5 years ago
!echo $PATH
屏幕快照 2019-07-29 下午10 58 08
!ls
屏幕快照 2019-07-29 下午10 58 29
! pwd
屏幕快照 2019-07-29 下午10 58 37
hupili commented 5 years ago

please execute those in the note book where error arose.

MindyZHAOMinzhu commented 5 years ago

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.

hupili commented 5 years ago

@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 commented 5 years ago

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.

MindyZHAOMinzhu commented 5 years ago

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

MindyZHAOMinzhu commented 5 years ago

I try to use terminal to get venv, but it seems I get the same path.

屏幕快照 2019-07-31 上午6 39 50
hupili commented 5 years ago

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

MindyZHAOMinzhu commented 5 years ago

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
hupili commented 5 years ago

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