title: Sympy -- AttributeError: 'tuple' object has no attribute 'right'
body: <p>I am trying to build a simple pendulum model in <code>sympy</code>. </p>
  
  <p>Does anyone know why I would be getting this error? </p>
  
  <p>The tutorial is here: </p>
  
  <p><a href="http://for.rest/articles/The-Spring-Pendulum-with-Sympy/" rel="nofollow noreferrer">http://for.rest/articles/The-Spring-Pendulum-with-Sympy/</a></p>
  
  <p>Here's the code. Note, I modified my code slightly because the tutorial picked a very unintuitive coordinate system(+y pointing down).</p>
  
  <pre><code>import sympy
  from sympy import symbols, init_printing
  import sympy.physics.mechanics as me
  init_printing()
  import matplotlib.pyplot as plt
  import numpy as np
  from pydy.system import System
  from numpy import linspace
  %matplotlib inline
  
  # Create the variables
  L, theta = me.dynamicsymbols('L theta')
  
  # Create the velocities
  L_dot, theta_dot = me.dynamicsymbols('L_dot theta_dot')
  
  # Create the constants
  m, g, t, L_0 = sympy.symbols('m g t L_0')
  
  # Create the world frame
  A = me.ReferenceFrame('A')
  
  # Create the pendulum frame
  B = A.orientnew('B', 'axis', [theta, A.z])
  
  # Set the rotation of the pendulum frame
  B.set_ang_vel(A, theta_dot * A.z)
  
  # Create the Origin
  O = me.Point('O')
  
  # Create the mass point
  P = O.locatenew('P', L * -B.y)
  
  # Display the mass point location in the A frame
  P.pos_from(O).express(A)
  
  # Set origin velocity to zero
  O.set_vel(A, 0)
  
  # Create the velocity of the mass point
  P.set_vel(B, L_dot * -B.y)
  P.v1pt_theory(O, A, B)
  
  P.vel(A).express(A)
  </code></pre>
  
  <p>The problem arises in the last line of code there. Note, the object <code>P.vel(A)</code> is type <code>sympy.physics.vector.vector.Vector</code>, which has <code>express</code> as a method. </p>
  
  <p>Here's the error</p>
  
  <pre><code>---------------------------------------------------------------------------
  AttributeError                            Traceback (most recent call last)
  C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\formatters.py in __call__(self, obj)
      691                 type_pprinters=self.type_printers,
      692                 deferred_pprinters=self.deferred_printers)
  --&gt; 693             printer.pretty(obj)
      694             printer.flush()
      695             return stream.getvalue()
  
  C:\ProgramData\Anaconda3\lib\site-packages\IPython\lib\pretty.py in pretty(self, obj)
      363                 if cls in self.type_pprinters:
      364                     # printer registered in self.type_pprinters
  --&gt; 365                     return self.type_pprinters[cls](obj, self, cycle)
      366                 else:
      367                     # deferred printer
  
  C:\ProgramData\Anaconda3\lib\site-packages\sympy\interactive\printing.py in _print_plain(arg, p, cycle)
       66         """caller for pretty, for use in IPython 0.11"""
       67         if _can_print_latex(arg):
  ---&gt; 68             p.text(stringify_func(arg))
       69         else:
       70             p.text(IPython.lib.pretty.pretty(arg))
  
  C:\ProgramData\Anaconda3\lib\site-packages\sympy\printing\pretty\pretty.py in pretty(expr, **settings)
     2162 
     2163     try:
  -&gt; 2164         return pp.doprint(expr)
     2165     finally:
     2166         pretty_use_unicode(uflag)
  
  C:\ProgramData\Anaconda3\lib\site-packages\sympy\printing\pretty\pretty.py in doprint(self, expr)
       60 
       61     def doprint(self, expr):
  ---&gt; 62         return self._print(expr).render(**self._settings)
       63 
       64     # empty op so _print(stringPict) returns the same
  
  C:\ProgramData\Anaconda3\lib\site-packages\sympy\physics\vector\vector.py in render(self, *args, **kwargs)
      283                                 pform = vp._print(
      284                                     ar[i][0][j])
  --&gt; 285                             pform = prettyForm(*pform.right(" ",
      286                                                 ar[i][1].pretty_vecs[j]))
      287                         else:
  
  AttributeError: 'tuple' object has no attribute 'right'
  </code></pre>
  
  <p>This creates a separate issue because, without expressing this, I can't run a computation later. </p>
  
  <pre><code>pendulum = me.Particle('pend', P, m)
  
  gravity = m * g * A.y
  forces = gravity 
  
  kane = me.KanesMethod(A,
                        q_ind=[L, theta],
                        u_ind=[L_dot, theta_dot],
                        kd_eqs=[L_dot - L.diff(t),
                        theta_dot - theta.diff(t)])
  </code></pre>
  
  <p>Which produces this error</p>
  
  <pre><code>---------------------------------------------------------------------------
  ValueError                                Traceback (most recent call last)
  &lt;ipython-input-222-aeb1b3bb40e8&gt; in &lt;module&gt;()
  ----&gt; 1 fr, frstar = kane.kanes_equations([(P, forces)], [pendulum])
  
  C:\ProgramData\Anaconda3\lib\site-packages\sympy\physics\mechanics\kane.py in kanes_equations(self, bodies, loads)
      537                     'kinematic differential equations to use this method.')
      538         fr = self._form_fr(loads)
  --&gt; 539         frstar = self._form_frstar(bodies)
      540         if self._uaux:
      541             if not self._udep:
  
  C:\ProgramData\Anaconda3\lib\site-packages\sympy\physics\mechanics\kane.py in _form_frstar(self, bl)
      332             v = [msubs(vel, self._qdot_u_map) for vel in vlist]
      333             return partial_velocity(v, self.u, N)
  --&gt; 334         partials = [get_partial_velocity(body) for body in bl]
      335 
      336         # Compute fr_star in two components:
  
  C:\ProgramData\Anaconda3\lib\site-packages\sympy\physics\mechanics\kane.py in &lt;listcomp&gt;(.0)
      332             v = [msubs(vel, self._qdot_u_map) for vel in vlist]
      333             return partial_velocity(v, self.u, N)
  --&gt; 334         partials = [get_partial_velocity(body) for body in bl]
      335 
      336         # Compute fr_star in two components:
  
  C:\ProgramData\Anaconda3\lib\site-packages\sympy\physics\mechanics\kane.py in get_partial_velocity(body)
      326                 vlist = [body.masscenter.vel(N), body.frame.ang_vel_in(N)]
      327             elif isinstance(body, Particle):
  --&gt; 328                 vlist = [body.point.vel(N),]
      329             else:
      330                 raise TypeError('The body list may only contain either '
  
  C:\ProgramData\Anaconda3\lib\site-packages\sympy\physics\vector\point.py in vel(self, frame)
      453         if not (frame in self._vel_dict):
      454             raise ValueError('Velocity of point ' + self.name + ' has not been'
  --&gt; 455                              ' defined in ReferenceFrame ' + frame.name)
      456         return self._vel_dict[frame]
      457 
  
  ValueError: Velocity of point P has not been defined in ReferenceFrame A
  </code></pre>