Python Bizarre Error - Variable Referenced Before Assignment

Charon

I keep on getting an UnboundLocalError: local variable 'res' referenced before assignment.

However, I'm absolutely positive that the variable is not referenced before assignment!

Here's my code:

def get_models(self,x=None,y=None):
        bioservices_up_obj = UniProt()
        bioservices_quickgo_obj = QuickGO()
        res = bioservices_quickgo_obj.Annotation_from_protein(protein=str(Brick.part_attrib(self,'uniprot_id')))
        go_id = []
        go_number = len(res['goID'])
        for i in range(go_number):
            go_id.append(str(res.iloc[i]['goID']))
        results = bioservices_up_obj.search(go_id[:go_number],format="tab",columns="id",sort="score",maxTrials=2)
        print results

All the other variables seem to print out fine, but for some reason I keep getting this error.

Emmett Butler

After checking the source of the library you're using

File "/usr/local/lib/python2.7/dist-packages/bioservices/uniprot.py", line 470, in search

It appears that line 470 does actually have a bug. Line 459 in the same file is commented out in the latest version, which appears to be causing the bug.

Downloaded the tarball from here, opened uniprot.py, observed:

#res = s.request("/uniprot/?query=zap70+AND+organism:9606&format=xml", params)
trials = 3
while trials<maxTrials:
    try:
        res = self.request("uniprot/?query=%s" % query + "&" + params, "txt")
        trials = maxTrials + 1
    except:
        self.logging.warning("Trying again...")
        import time
        time.sleep(2)
        trials += 1
return res

Notice the commented first line (line 459 in the file). You could experiment with uncommenting that line, but I'm unfamiliar with the library so I don't know what that might do.

The project bug tracker is here, maybe you could submit a bug report.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

UnboundLocalError: local variable 'error' referenced before assignment

From Dev

Solving error: local variable 'counter' referenced before assignment

From Dev

python2.7 error: UnboundLocalError: local variable 'i' referenced before assignment

From Dev

UnboundLocalError: local variable 'L' referenced before assignment Python

From Dev

Cython compilation error - local variable referenced before assignment

From Dev

'Local variable referenced before assignment' error, due to confusion with function name?

From Dev

error UnboundLocalError: local variable 'currentpl' referenced before assignment:

From Dev

UnboundLocalError: local variable referenced before assignment in python closure

From Dev

UnboundLocalError: local variable 'X' referenced before assignment Python for simbols fixer

From Dev

Error: Local variable referenced before assignment

From Dev

Python (3.3): UnboundLocalError: local variable referenced before assignment

From Dev

Python: UnboundLocalError: local variable 'count' referenced before assignment

From Dev

Python Error - UnboundLocalError: local variable referenced before assignment

From Dev

MySQLdb error local variable referenced before assignment (different than usual)

From Dev

python err: Local variable referenced before assignment

From Dev

Cython compilation error - local variable referenced before assignment

From Dev

Variable referenced before assignment in this code

From Dev

Python - local variable referenced before assignment

From Dev

Python 3: "Local Variable referenced before assignment"

From Dev

Multiprocessing in python - UnboundLocalError: local variable 'data' referenced before assignment

From Dev

UnBoundLocalError: local variable referenced before assignment (Python)

From Dev

UnboundLocalError: local variable 'X' referenced before assignment Python for simbols fixer

From Dev

Python Error - UnboundLocalError: local variable referenced before assignment

From Dev

Local variable referenced before assignment Python 3.4.5

From Dev

Local variable '...' referenced before assignment

From Dev

local variable referenced before assignment

From Dev

local variable referenced before assignment django error

From Dev

Django form error:local variable 'context' referenced before assignment

From Dev

global variable referenced before assignment

Related Related

  1. 1

    UnboundLocalError: local variable 'error' referenced before assignment

  2. 2

    Solving error: local variable 'counter' referenced before assignment

  3. 3

    python2.7 error: UnboundLocalError: local variable 'i' referenced before assignment

  4. 4

    UnboundLocalError: local variable 'L' referenced before assignment Python

  5. 5

    Cython compilation error - local variable referenced before assignment

  6. 6

    'Local variable referenced before assignment' error, due to confusion with function name?

  7. 7

    error UnboundLocalError: local variable 'currentpl' referenced before assignment:

  8. 8

    UnboundLocalError: local variable referenced before assignment in python closure

  9. 9

    UnboundLocalError: local variable 'X' referenced before assignment Python for simbols fixer

  10. 10

    Error: Local variable referenced before assignment

  11. 11

    Python (3.3): UnboundLocalError: local variable referenced before assignment

  12. 12

    Python: UnboundLocalError: local variable 'count' referenced before assignment

  13. 13

    Python Error - UnboundLocalError: local variable referenced before assignment

  14. 14

    MySQLdb error local variable referenced before assignment (different than usual)

  15. 15

    python err: Local variable referenced before assignment

  16. 16

    Cython compilation error - local variable referenced before assignment

  17. 17

    Variable referenced before assignment in this code

  18. 18

    Python - local variable referenced before assignment

  19. 19

    Python 3: "Local Variable referenced before assignment"

  20. 20

    Multiprocessing in python - UnboundLocalError: local variable 'data' referenced before assignment

  21. 21

    UnBoundLocalError: local variable referenced before assignment (Python)

  22. 22

    UnboundLocalError: local variable 'X' referenced before assignment Python for simbols fixer

  23. 23

    Python Error - UnboundLocalError: local variable referenced before assignment

  24. 24

    Local variable referenced before assignment Python 3.4.5

  25. 25

    Local variable '...' referenced before assignment

  26. 26

    local variable referenced before assignment

  27. 27

    local variable referenced before assignment django error

  28. 28

    Django form error:local variable 'context' referenced before assignment

  29. 29

    global variable referenced before assignment

HotTag

Archive