Update:
It's quite likely that you have a file called numpy.py
in another directory.
When you run testfile.py
in your terminal, you are inside of your directory 'numpy' which does not have a file numpy.py
and that's why it finds the correct numpy-module.
However, in PyCharm you can add directories to Sources Root (i.e. sys.path
as explained in this answer) which apparently contains a file called numpy.py
. Remove that directory from your sys.path
(as explained by jetbrains) and it should also work in PyCharm.
Old answer (wrong!):
As of my knowledge, the directory name does not interfere with module names unless maybe you define your directory as a package using __init__.py
You need to be careful with how you name your directories. It's possible that the Python interpreter uses your directory 'numpy' to find the function 'array()' instead of using the PyPI numpy-module. Re-naming that directory might fix your issue.
So, e.g. "/Users/giridhar/PycharmProjects/my-numpy/testfile"