How to fix AttributeError: module 'numpy' has no attribute 'square'

84,566

I removed numpy.py then updated my numpy and it worked!

Share:
84,566

Related videos on Youtube

Hoda Fakharzadeh
Author by

Hoda Fakharzadeh

Updated on January 21, 2020

Comments

  • Hoda Fakharzadeh
    Hoda Fakharzadeh over 4 years

    I have updated numpy to 1.14.0. I use Windows 10. I tried to run my code and I got this error:

    AttributeError: module 'numpy' has no attribute 'square'

    Here are my imports:

    %matplotlib inline
    import matplotlib.pyplot as plt
    import tensorflow as tf
    import numpy as np
    from sklearn.metrics import confusion_matrix
    import math
    
    • user2357112
      user2357112 over 6 years
      If you called a file numpy.py, pick a different name (and delete the corresponding numpy.pyc if there is one).
    • ShpielMeister
      ShpielMeister over 6 years
      show the entire code and the entire error
    • Hoda Fakharzadeh
      Hoda Fakharzadeh over 6 years
      @user2357112 I did as u said but my new error is :module 'numpy' has no attribute '__version__'
    • mikey
      mikey about 4 years
      I got this error when loading matplotlib
  • Ryan
    Ryan over 5 years
    I ran conda update --all, pip uninstall -y numpy, pip uninstall -y setuptools, pip install setuptools==39.1.0, and pip install numpy and that seemed to solve that error about "'numpy' has no attribute 'square'".
  • Shibani
    Shibani over 4 years
    The above solution works, except that I didn't hardcode the version. uninstalling numpy and scipy, and just re-installing them.