NameError: name 'zeros' is not defined

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tshravan
    New Member
    • Mar 2008
    • 1

    #1

    NameError: name 'zeros' is not defined

    Hello All,

    I am newbie to python.

    I was trying to use a=zeros(5) in python shell, but it is throwing the following exception in the shell

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'zeros' is not defined

    My environment is
    O/s : Ubuntu 7 (gutsy)
    Python : 2.5.1

    Could anyone tell me how to solve this problem?

    Thank you very much well in advance.

    Regards,
    Shravan
  • jlm699
    Contributor
    • Jul 2007
    • 314

    #2
    I believe that zeros is a function that belongs to numpy (or Numeric?):

    [code=python]
    >>> import numpy
    >>> numpy.zeros(5, int)
    array([0, 0, 0, 0, 0])[/code]

    Comment

    Working...