0

When using, for example numpy, in a file named numpy.py an error occurs:

AttributeError: partially initialized module 'numpy' has no attribute '__version__' (most likely due to a circular import)

LiteralGoat
  • 121
  • 1
  • 7

1 Answers1

1

As explained in the python documentation, a "module is a file containing Python definitions and statements [and the] file name is the module name with the suffix .py appended." So by naming your file numpy.py, and then trying to import numpy in that module, you have two different imports of numpy.

You never want to give a script the same name as a common module, such as pandas, numpy, or anything in the standard library. Instead, rename the script file to numpy_examples.py or something like it, and it should solve your problem.

Eric Truett
  • 2,970
  • 1
  • 16
  • 21