-1

I just installed Python, and did add both

"C:\Users\xxxxx\AppData\Local\Programs\Python\Python310"

"C:\Users\xxxxx\AppData\Local\Programs\Python\Python310\Scripts"

in the path environment variable.

In the cmd, I can call pip with no problem.

But I can't seems to run the python code with python .\myproject.py, and there is no error text print.

Nothing print, no error or warning message, it just ended.

So I run a simple print file which still not print anything.

The test file is just :

def main():
  print("Hi")

if __name__ == "__main__":
  main()
benson23
  • 16,369
  • 9
  • 19
  • 38
  • In the command line in the directory try the command `py myproject.py` – Carl_M Mar 07 '22 at 17:01
  • It worked! Is there a setting or version that makes the difference? I think I was using python 3.7 or 3.8 and I was using "python" to call the script. – Johnson Peter Mar 07 '22 at 17:08
  • I think I found the difference: https://stackoverflow.com/questions/50896496/what-is-the-difference-between-py-and-python-in-the-windows-terminal. But Does anyone know why my Path does not work for "python" command? – Johnson Peter Mar 07 '22 at 17:16
  • Hmm. Windows Path gets set for a session (probably not the right word). So, if you have a Terminal (command prompt) open before you updated the path variable, you don't see it in that session. You at least need to close and reopen your command prompt. If that doesn't do it, you might have to log out and into Windows. It is hard to know without additional detail. – cadvena Mar 07 '22 at 17:33

1 Answers1

0

The problem solved after I Modify the installation of Python which check the option "Add Python to environment variables".

I think following article helps to understand the issue and difference:

What is the difference between 'py' and 'python' in the Windows terminal?

'py' works but not 'python' in command prompt for windows 10