Table of Contents

Name Conflict

Name of Python script must not be the same as the name of the package you are using in the script. Otherwise, it will cause a conflict.

pip install numpy

Then, create a script named numpy.py.

import numpy as np
print(np.array([1, 2, 3]))

When you run the script, it will raise an error.

python numpy.py

# or
python -c "import numpy as np; print(np.array([1, 2, 3]))"

# Traceback (most recent call last):
#   File "/home/xxx/python-sandbox/numpy.py", line 1, in <module>
#     import numpy as np
#   File "/home/xxx/python-sandbox/numpy.py", line 3, in <module>
#     print(np.array([1, 2, 3]))
#           ^^^^^^^^
# AttributeError: partially initialized module 'numpy' has no attribute 'array' (most likely due to a circular import)

The script numpy.py must be renamed like execute-numpy.py to avoid the conflict.