Mechanize: Difference between revisions
From charlesreid1
No edit summary |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 13: | Line 13: | ||
export INSTALL_PATH="/path/to/mechanize" | export INSTALL_PATH="/path/to/mechanize" | ||
# create the | # create the mechanize library site packages directory | ||
export PACKAGE_PATH="${INSTALL_PATH}/lib/python2.7/site-packages" | export PACKAGE_PATH="${INSTALL_PATH}/lib/python2.7/site-packages" | ||
mkdir -p $PACKAGE_PATH | |||
# add the site packages to the PYTHONPATH variable | # add the mechanize library site packages directory to the PYTHONPATH variable so Python knows where the mechanize library is | ||
export PYTHONPATH=${PACKAGE_PATH}:${PYTHONPATH} | export PYTHONPATH="${PACKAGE_PATH}:${PYTHONPATH}" | ||
# build | # build | ||
| Line 35: | Line 36: | ||
</pre> | </pre> | ||
[[Category:Web Scraping]] | |||
[[Category:Python]] | |||
Latest revision as of 19:07, 26 August 2015
Installation
Download from the Mechanize page here: http://wwwsearch.sourceforge.net/mechanize/download.html
Configure/Build
First, pick a destination directory for mechanize. I'll use /path/to/mechanize as an example.
Next, run the following commands:
# set installation path
export INSTALL_PATH="/path/to/mechanize"
# create the mechanize library site packages directory
export PACKAGE_PATH="${INSTALL_PATH}/lib/python2.7/site-packages"
mkdir -p $PACKAGE_PATH
# add the mechanize library site packages directory to the PYTHONPATH variable so Python knows where the mechanize library is
export PYTHONPATH="${PACKAGE_PATH}:${PYTHONPATH}"
# build
python ./setup.py build
# install
python ./setup.py install --prefix=$[INSTALL_PATH}
The last step is to permanently add /path/to/mechanize/lib/python2.7/site-packages to your $PYTHONPATH in your .profile or .bashrc or wherever you set your $PYTHONPATH variable.
To test it out, open Python and run the command:
>>> import mechanize >>>