title: How do I fix the 'TypeError: hasattr(): attribute name must be string' error?
body: <p>I have the following code:</p>
  
  <pre><code>import pymc as pm
  from matplotlib import pyplot as plt
  from pymc.Matplot import plot as mcplot
  import numpy as np
  from matplotlib import rc
  
  res = [18.752, 12.450, 11.832]
  
  v = pm.Uniform('v', 0, 20)
  
  errors = pm.Uniform('errors', 0, 100, size = 3)
  
  taus = 1/(errors ** 2)
  
  mydist = pm.Normal('mydist', mu = v, tau = taus, value = res, observed = True)
  
  model=pm.Model([mydist, errors, taus, v, res])
  mcmc=pm.MCMC(model) # This is line 19 where the TypeError originates
  mcmc.sample(20000,10000)
  
  mcplot(mcmc.trace('mydist'))
  </code></pre>
  
  <p>For some reason it doesn't work, I get the 'TypeError: hasattr(): attribute name must be string' error, with the following trace:</p>
  
  <pre><code> Traceback (most recent call last):
  
    File "&lt;ipython-input-49-759ebaf4321c&gt;", line 1, in &lt;module&gt;
  runfile('C:/Users/Paul/.spyder2-py3/temp.py', wdir='C:/Users/Paul/.spyder2-py3')
  
    File "C:\Users\Paul\Miniconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 685, in runfile
  execfile(filename, namespace)
  
    File "C:\Users\Paul\Miniconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 85, in execfile
  exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)
  
    File "C:/Users/Paul/.spyder2-py3/temp.py", line 19, in &lt;module&gt;
  mcmc=pm.MCMC(model)
  
    File "C:\Users\Paul\Miniconda3\lib\site-packages\pymc\MCMC.py", line 82, in __init__
  **kwds)
  
    File "C:\Users\Paul\Miniconda3\lib\site-packages\pymc\Model.py", line 197, in __init__
  Model.__init__(self, input, name, verbose)
  
    File "C:\Users\Paul\Miniconda3\lib\site-packages\pymc\Model.py", line 99, in __init__
  ObjectContainer.__init__(self, input)
  
    File "C:\Users\Paul\Miniconda3\lib\site-packages\pymc\Container.py", line 606, in __init__
  conservative_update(self, input_to_file)
  
    File "C:\Users\Paul\Miniconda3\lib\site-packages\pymc\Container.py", line 549, in conservative_update
  if not hasattr(obj, k):
  
  TypeError: hasattr(): attribute name must be string
  </code></pre>
  
  <p>How do I make it work and output "mydist"?</p>
  
  <p>Edit: I posted a wrong trace at first by accident.</p>
  
  <p>Edit2: It all must be because res doesn't have a name, because it's an array, but I don't know how to assign a name to it, so it'll make this work.</p>