How can I tell if Python setuptools is installed?

Try with this command.

$ pip list

It returns the versions of both pip and setuptools. Otherwise try with

$ pip install pil

If this also doesn't work, then try with

$ which easy_install

Just run the following code into IDLE:

import easy_install

If it just goes to the next line, I think it's installed. If it says:

Error: invalid syntax

Then it probably isn't installed. I know this because I tested pip with it. Also just check import pip to see if pip is pre-installed. :)


you can check for easy_install and setuptools by running the following command line commands:

which easy_install
#finds the path to easy_install if it exists

less path/to/easy_install
#where path/to/easy_install is the output from the above command
#this outputs your easy_install script which will mention the version of setuptools

If the easy_install/setuptools bundle is installed, your output from the second command above will probably read something like this:

#EASY-INSTALL-ENTRY-SCRIPT: 'setuptools==0.6c11','console_scripts','easy_install'

This isn't great but it'll work.

A simple python script can do the check

import sys
try:
    import setuptools
except ImportError:
    sys.exit(1)
else:
    sys.exit(0)

OR

try:
    import setuptools
except ImportError:
    print("Not installed.")
else:
    print("Installed.")

Then just check it's exit code in the calling script