0

I have a Python script that I want to run as part of a Jenkins project. When I try to run the script via Jenkins, I get an ImportError when it tries to find the gearman module. (Yes, the gearman module is installed on the slave node - I am able to run an interactive Python shell and can successfully import this module.)

This is the exact error:

+ python test.py
Traceback (most recent call last):
  File "test.py", line 2, in <module>
    import gearman, time, sys
ImportError: No module named gearman

How do I let Jenkins know where to look for modules? Thanks!

user2406467
  • 1,017
  • 6
  • 18
  • 22
  • Dupe of http://stackoverflow.com/questions/12995809/jenkins-putting-my-python-module-on-the-pythonpath – Eli May 30 '13 at 21:43
  • I already tried setting a build step (Python script): ` import sys import os # jenkins exposes the workspace directory through env. sys.path.append(os.environ['WORKSPACE']) import gearman` And it fails on the import. – user2406467 May 30 '13 at 21:47
  • See my answer below. Try setting your PYTHONPATH in the build step. – Eli May 30 '13 at 21:53

1 Answers1

2

There's much more information here, but the simplest answer to your question is, in your jenkins build configuration, configure the build step with:

export PYTHONPATH=$PATH_TO_MODULE:$PYTHONPATH
Community
  • 1
  • 1
Eli
  • 36,793
  • 40
  • 144
  • 207
  • I think I got confused because it was an .egg file. I was pointing to the wrong place on top of this. Thanks! :) – user2406467 May 30 '13 at 21:55