Search code examples
pythonmechanizeeasy-install

installing mechanize with easy_install


I just got easy_install downloaded but i'm having problems installing mechanize, should I be addressing site-packages at any point. In the first try below, i got an error. in the second try below, i got command not found which is wierd since I know for sure that it downloaded.

names-computer:~ names$ cd /Users/names/Desktop/
names-computer:~/Desktop names$ sh /Users/names/Desktop/mechanize-0.1.9-py2.5.egg
/Users/names/Desktop/mechanize-0.1.9-py2.5.egg: /Users/names/Desktop/mechanize-0.1.9-py2.5.egg: cannot execute binary file

names-computer:~/Desktop names$ easy_install mechanize
-bash: easy_install: command not found

Solution

  • On OS X, Python interpreter instances are typically installed as so-called Framework builds which means that there is a bin directory within the framework which is typically (but not always) the installation destination for python scripts, such as easy_install. If you are not using the Apple-supplied python (in /usr/bin/) which has its own easy_install instance there, you should ensure that the framework bin directory of the desired python is on your shell search PATH and precedes /usr/bin. In particular, if you are using the python installed by the python.org installer, your PATH should look something like this:

    $ echo $PATH
    /Library/Frameworks/Python.framework/Versions/2.6/bin:/usr/bin:/bin
    

    That ensures that the proper easy_install will be found first. If you are using a MacPorts python, it should look like this:

    $ echo $PATH
    /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin:/opt/local/bin:/usr/bin:/bin
    

    EDIT: By the way, the egg that you downloaded appears to be for Python 2.5 and judging from a previous question, you may be wanting to use it with python 2.6. If you just use the command

    $ easy_install mechanize
    

    it should automatically download the proper egg, if available, or the source and do the necessary build and install steps.