Including Incanter in Leiningen projects

The latest stable version of Incanter is version 1.2.2 and is available on Clojars. To include the full Incanter distribution in your project, add the following line to your Leiningen project.clj file:
[incanter "1.2.2"]
To include just a subset of Incanter, use one, or more, of the following modules instead.

[incanter/incanter-core "1.2.2"]
[incanter/incanter-charts "1.2.2"]
[incanter/incanter-processing "1.2.2"] 
You can also use the latest development snapshots
[incanter "1.2.3-SNAPSHOT"]
[incanter/incanter-core "1.2.3-SNAPSHOT"]
[incanter/incanter-charts "1.2.3-SNAPSHOT"]
[incanter/incanter-processing "1.2.3-SNAPSHOT"] 

Example Project

Start a new project with Leiningen

$ lein new myproject
$ cd myproject
Edit the project.clj file:
(defproject myproject "1.0.0-SNAPSHOT" 
  :description "Example Incanter project" 
  :dependencies [[incanter "1.2.3-SNAPSHOT"]])

Download your project's dependencies, including Incanter:

$ lein deps
Test it out by starting a REPL, loading a couple libraries, plotting the sin function:
$ java -cp 'lib/*' clojure.main
user=> (use '(incanter core charts))
user=> (view (function-plot sin -10 10))

WARNING: 'lein repl' does not work correctly with Incanter version 1.2 because the Leiningen repl task uses version 1.1 of Clojure. In order to start a REPL from a Leiningen project, I recommend creating a script directory in your project directory and placing one of the following repl scripts in it,, repl.bat (scripts stolen from Stuart Halloway's labrepl project).

See "Building Incanter applications with Leiningen" and "Building a Clojure Web application with Incanter, Compojure, and Leiningen" for more examples of building Incanter apps with Leiningen.

Using version 1.0 of Incanter

If you require Clojure 1.1 (instead of 1.2 or greater), then you will need to use Incanter version 1.0 which is not available on Clojars. The following instructions will get you started.

Edit your project.clj file

Add to your project's list of repositories,

:repositories {"incanter" ""}

then add Incanter 1.0.0 as a dependency
[org.incanter/incanter-full "1.0.0"]
or use one of its submodules instead.
[org.incanter/incanter-core "1.0.0"] 
[org.incanter/incanter-charts "1.0.0"] 
[org.incanter/incanter-processing "1.0.0"]
Here's an example project.clj file:
(defproject myproject "1.0.0-SNAPSHOT" 
  :description "Example Incanter project" 
  :repositories {"incanter" ""} 
  :dependencies [[org.incanter/incanter-full "1.0.0"]])

©2010 David Liebke
Fork me on GitHub