12

I have already done pip install jira

but when I run the following it fails with ImportError: cannot import name JIRA

import re
from jira import JIRA

jira = JIRA('https://issues.net')
# all values are samples and won't work in your code!
key_cert_data = None
key_cert_file = "cert/jiraprivatekey.pub"
with open(key_cert, 'r') as key_cert_file:
    key_cert_data = key_cert_file.read()
2

4 Answers 4

38

fixed it.

The file I was running was called jira.py so when I did from

jira import JIRA

It was trying to look up self.

Sign up to request clarification or add additional context in comments.

3 Comments

I'd like to note that you can turn on absolute import paths and keep your file named jira.py if it makes sense to you to do that
@std''OrgnlDave Can you explain how?
@MonkeyMonkey added an answer explaining how
0

In addition to @Organ note

I'd like to note that you can turn on absolute import paths and keep your file named jira.py if it makes sense to you to do that

In my case, I did this twice:

from jira import JIRA
jira = JIRA(URL_JIRA, basic_auth=('abc', '123'))

So in the first show, it's working good because jira is the global namespace but in second usage it doesn't because jira became just instance of JIRA.

This is my solution based on Organ's note:

import jira.client
x = jira.client.JIRA(URL_JIRA, basic_auth=('123', 'abc'))

Here, you can keep having jira.py and use these lines as much as you need.

Comments

0

I started getting this error when I installed python 3.6,earlier I had python 2.7. and jira was working. I renamed the python3.6 exe as python3 and python 2.7 exe as python, issue got resolved

Comments

0

In my case from jira import Jira was resolved with next steps:

  1. run in command line under (venv) :
pip install jira 
pip install 'jira[cli]'

or if you are not in (venv):

pip install jira 
python -m venv jira_python
source jira_python/bin/activate
pip install 'jira[cli]'
  1. Add into block of imports of your *.py file:
from jira import JIRA
jira = JIRA('https://jira.atlassian.com')

The official doc you will find here:
https://jira.readthedocs.io/installation.html
and here:
https://pypi.org/project/jira/

Hope somebody it will helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.