When I call a python file from the CMD prompt in Windows 10 I get an error, when I type the same 2 lines of code into the interpreter it works (copied and pasted from the saved python file).
First saw the issue in VSCode when I tried 'Run Python File in Terminal' so I tried directly in the CMD prompt (output pasted below). Got the same result, then tried PowerShell which did the same thing.
Running version 3.7.4 as seen in the output from the command prompt below. I've also tried 3.6.x versions. Pandas installed via latest pip.
I previously had version 3.3.x installed (as well-as a 2.x version) but both were removed prior to installing 3.7.4 and pandas.
I've uninstalled python (all versions, the new version multiple times) then re-installed. Same with VSCode (including clearing all user preferences and extensions). Verified the PATH variable. Always getting the same result.
C:\WINDOWS\system32>python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>> print(pandas.read_excel("C:\pandas\worldcities.xlsx"))
{{THIS WORKS, RESULTS REMOVED FOR BREVITY}}
[12959 rows x 11 columns]
>>> exit()
C:\WINDOWS\system32>python C:\pandas\pandas.py
Traceback (most recent call last):
File "C:\pandas\pandas.py", line 1, in <module>
import pandas
File "C:\pandas\pandas.py", line 2, in <module>
print(pandas.read_excel("C:/pandas/worldcities.xlsx"))
AttributeError: module 'pandas' has no attribute 'read_excel'
I would expect the output from passing the file into python to be the same as the output from directly typing the same 2 commands into the python interpreter running in the CMD prompt.