Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UnboundLocalError: local variable 'arith_flex' referenced before assignment

I was teaching a workshop today, and 5 people in my class had the error mentioned above when they used the line import pandas as pd.

Here's the traceback:

enter image description here

I've never heard of this variable before, and there was no mention of this particular issue with pandas in this particular context.

Some background:

  • These people were on corporate computers, so there may have been permissions denied to them on their own computer
  • They couldn't get regular Anaconda Navigator working, so they were using miniconda
  • This error message showed up when they tried to import pandas and seaborn, but not matplotlib or sklearn
  • they had done the install a week before, and no one mentioned having touched the software in the meantime
  • this simulaltaneously happened on 5 different people's computers

Any idea what the issue may have been?

like image 206
Jonathan Bechtel Avatar asked Jul 26 '19 20:07

Jonathan Bechtel


People also ask

How do you fix UnboundLocalError local variables referenced before assignment?

The Python "UnboundLocalError: Local variable referenced before assignment" occurs when we reference a local variable before assigning a value to it in a function. To solve the error, mark the variable as global in the function definition, e.g. global my_var .

How to handle UnboundLocalError in Python?

The UnboundLocalError: local variable referenced before assignment error is raised when you try to assign a value to a local variable before it has been declared. You can solve this error by ensuring that a local variable is declared before you assign it a value.


1 Answers

I had the same issue. I uninstalled Pandas and reinstalled with version 0.25.1 which seemed to fix the issue. Must have been a bug.

like image 149
HMan06 Avatar answered Dec 24 '22 14:12

HMan06