user2406467
user2406467

Reputation: 1047

ImportError when running Python script in Jenkins

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!

Upvotes: 0

Views: 15171

Answers (1)

Eli
Eli

Reputation: 39009

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

Upvotes: 2

Related Questions