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()
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.
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.