1

Hi I'm running a python script that transitions tickets from "pending build" to "in test" in Jira. I've ran it on my local machine (Mac OS X) and it works perfectly but when I try to include it as a build task in my bamboo deployment, I get the error

"from jira import JIRA

ImportError: No module named jira"

I'm calling the python file from a script task like the following "python myFile.py" and then I supply the location to the myFile.py in the working subdirectory field. I don't think that is a problem because the error shows that it is finding my script fine. I've checked multiple times and the jira package is in site-packages and is in the path. I installed using pip and am running python 2.7.8. The OS is SuSE on our server

Karsten Andersen
  • 115
  • 5
  • 16
  • 2
    Are you sure that a call to 'python' uses the same python binary and site-packages that a call to 'pip' uses? You may find pip's version and your connected python version by supplying 'pip - -version'. After you checked that, do a 'pip freeze' to list all installed packages and double check if jira actually got installed. When within the Python Interactive Interpreter, you can also do a 'help()' followed by a 'modules' to list all modules locally installed for that interpreter. – FMaz Aug 11 '16 at 16:58
  • I did all the of those and jira is clearly listed and pip is connected to the right python version. Still don't know what is wrong – Karsten Andersen Aug 11 '16 at 18:54
  • I had the same issue. The error occured when I ran that test.py with python3 instead of python 2.*. I previously installed it using `pip install --user jira` – MonkeyMonkey Jun 21 '17 at 15:28

2 Answers2

1

That is very hard to understand what you problem is. From what I understood you are saying that when you run your module as standalone file, everything works, but when you imoprt it you get an error. Here are some steps towards solving the problem.

  1. Make sure that your script is in Python package. In order to do that, verify that there is (usually) empty __init__.py file in the same directory where the package is located.
  2. Make sure that your script does not import something else in the block that gets executed only when you run the file as script (if __name__ == "__main__")
  3. Make sure that the python path includes your package and visible to the script (you can do this by running print os.environ['PYTHONPATH'].split(os.pathsep)
Dmitry Torba
  • 3,004
  • 1
  • 14
  • 24
  • I don't think that you understand his problem correctly. @Karsten Maybe you should reword your question? – FMaz Aug 11 '16 at 18:57
  • So yes as a standalone it works but when I try to run it through bamboo on our build machine (SuSE) as a script task, I receive the import error. The jira package was downloaded to the build machine using pip and is in the site-packages directory for python. It is also listed in the PYTHONPATH but yet for some reason I receive the import error still. Hope that better explains it. – Karsten Andersen Aug 11 '16 at 18:58
0

Confirm that you don't have another file or directory that shares the same name as the module you are trying to import.

martin
  • 1
  • 2
  • Welcome to StackOverflow. One-liners are generally not well suited as answers. You should try to expand your answer or post it as a comment instead. – AfroThundr Feb 13 '18 at 19:12