[Tutor] how to move an executable into path

Steven D'Aprano steve at pearwood.info
Sun Nov 27 12:03:08 EST 2016


On Tue, Nov 22, 2016 at 06:33:35PM -0600, Benjamin Fishbein wrote:

> Everything was going fine with my selenium webdriver programs, but 
> then today I updated to Firefox 50. Everything stopped working.

That's what happens when you upgrade Firefox -- you get something 
which does more of the things you don't want, less of the things you do 
want, may or may not fix some security vulnerabilities, but absolutely 
will introduce new ones.

That's called "progress".

> So I updated to selenium 3, hoping this would work. But apparently I 
> need something called geckodriver.

"Something"? Care to give a hint what it is? I'm assuming it isn't a 
Python library.


> I managed to download this, but it’s in the wrong place: in my downloads folder.
[...]
> WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

That's not talking about the PYTHONPATH, which is the set of folders 
that Python looks for modules and libraries, but in your operating 
system's PATH, which is where the OS looks for executable programs, 
system libraries, and other goodies.

Does Mac offer some sort of officially supported package management? If 
so, you should use that. On Linux, I would firstly try:

sudo yum install geckodriver

or 

sudo apt-get install geckodriver

which (hopefully) would install the officially supported version. 
(Which, of course, might not be the version that Selenium and Firefox 50 
require. There's that progress again.)

But I fear that being on a Mac, any official package management is going 
to support Apple software and very little else.

You might try googling for "Homebrew", I think that's some sort of 
third-party package manager for OS X. See if you can use that to install 
geckodriver.

If not, well, things will start getting complicated fast. It depends on 
whether you have downloaded a binary library or the source code for 
geckodriver. You could try right-clicking on the file and seeing what 
sort of file the Finder thinks it is.

Wait, Mac's don't support right-click by default. Control-click perhaps?

*If* you have downloaded the source code, it will probably be in a 
tarball or zip file. You'll need to expand the zip file. Hopefully there 
will be a READ ME file in the zip file with decent instructions. If it 
is anything like Linux, you'll probably be told to open a shell window, 
cd into the directory containing the geckodriver source code, then run a 
series of commands like:

./configure
make
sudo make install

Those three commands will prepare the source code, compile it, and 
(hopefully) place it somewhere in the PATH.

If its not like Linux, well, it could be anything. (Sorry, I haven't 
seriously used a Mac since System 7.)

On the other hand, if you have downloaded the binary library, then no 
compilation is required. All you need to do is insert the file in one of 
the system directories that is on the PATH. I have no idea how to do 
that on OS X.

> So I’m not sure where the geckodriver file needs to go. Can it be 
> anywhere on the path? could I just put it in the site-packages folder 
> for example?

No, not site-packages, because that's for Python modules, not system 
libraries.


> And here’s the big problem: all of these folders are hidden, and I 
> have no idea how to get into them.

Start with this: open a terminal or shell window. You will see a prompt, 
probably a $ sign or maybe a % sign. If you see a >>> prompt, you're in 
the Python interpreter. You don't want that.

Type this command, and press the ENTER key:

echo $PATH

This will(?) print the current value of the system PATH. (At least 
it will on Linux -- on Mac, who knows?) Copy and paste the results here.


-- 
Steve


More information about the Tutor mailing list