AttributeError: 'Magic' object has no attribute 'cookie' while using python-jira

2.1k views Asked by At

I've run into this issue while using the jira library for python. Despite setting the appropriate parameters for basic auth, I get the following:

Exception ignored in: <bound method Magic.del of <magic.Magic object at 0x7f2a4e5ff128>> Traceback (most recent call last): File "/home/keckj/.local/lib/python3.6/site-packages/magic.py", line 129, in del if self.cookie and magic_close: AttributeError: 'Magic' object has no attribute 'cookie'

Here's a quick snippet:

from jira import JIRA

user = '[email protected]'
apikey = 'xxxxxxxxxxxxxxxxxxxxx'
jira_server = 'https://xxxxxxxxxx.jira.com'
options = {'server': jira_server}

jira = JIRA(options, basic_auth=(user,apikey))

issue = jira.issue("KEY-123")
issue_summary = issue.fields.summary
issue_description = issue.fields.description
print('JIRA ISSUE SUMMARY: %s' %str(issue_summary))
print('JIRA ISSUE DESCRIPTION: %s' %str(issue_description))

I've dug in a few directions via Google but been coming up short:

2

There are 2 answers

0
Jack Keck On

I found the answer buried at bottom of https://github.com/ahupp/python-magic/pull/222:

Apparently python-jira expects the filemagic python package, which takes a flags parameter, but for some reason our environment had your python-magic package, which expects different parameters.

Direct link: https://github.com/ahupp/python-magic/pull/222#issuecomment-675354824

To resolve this, I ran pip install filemagic and voila, no further exceptions.

0
Mark Hattarki On

I tried the "pip install filemagic", but it didn't fix it. It looks like the python-magic module is still installed, and getting picked up. However, another library I use, thehive4py lists python-magic as a dependancy.

You have to also uninstall python-magic at both the system (sudo) and user level. "pip3 uninstall python-magic". But, as stated before, it might/will break other libraries.

Why would someone think it is a good idea to have pip modules with conflicting names? Then, have one throw an error due to poor programing practices. jeesh.