0

I just installed Python and VScode yesterday. I was trying to use pip to install updates but the command python doesn't work. However py does. I'm wondering why this is and if there's a way to make the command python recognized.

In addition, I was wondering if there was a quicker way to run the terminal/shortcut alternative to right-clicking then selecting Run Python File in Terminal.

Lastly, I wanted to understand if I messed up during installation, because when I ran setx PATH "%PATH%;C:\Python34\Scripts" then echo %PATH%, instead of a seeing C:\Python34\Scripts I see a huge block of paths like:

C:\Program Files (x86)\Razer\ChromaBroadcast\bin;C:\Program Files\Razer\ChromaBroadcast\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Users\yiyan\AppData\Local\Microsoft\WindowsApps;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\Razer\ChromaBroadcast\bin;C:\Program Files\Razer\ChromaBroadcast\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Users\yiyan\AppData\Local\Microsoft\WindowsApps;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\Razer\ChromaBroadcast\bin;C:\Program Files\Razer\ChromaBroadcast\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\ProgramData\Oracle\Java\javapath;C:\W

Thank you for your time!

FortyTwo
  • 2,414
  • 3
  • 22
  • 33
teleluck
  • 35
  • 4

3 Answers3

0

Your path output is limited by lenght - your path is way longer and cut at C:\W - google how to inspect your path using windows methods: edit path and check it.

You should cleanup your path variable - it is way too long and has duplicates in it:

t = r"""C:\Program Files (x86)\Razer\ChromaBroadcast\bin;C:\Program Files\Razer\ChromaBroadcast\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Users\yiyan\AppData\Local\Microsoft\WindowsApps;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\Razer\ChromaBroadcast\bin;C:\Program Files\Razer\ChromaBroadcast\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Users\yiyan\AppData\Local\Microsoft\WindowsApps;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\Razer\ChromaBroadcast\bin;C:\Program Files\Razer\ChromaBroadcast\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\ProgramData\Oracle\Java\javapath;C:\W"""

from collections import Counter    
print (Counter(t.split(";")))

Output:

Counter(
    {'C:\\WINDOWS\\system32': 4, 
     'C:\\WINDOWS': 4, 
     'C:\\WINDOWS\\System32\\Wbem': 4,
     'C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\': 4,
     'C:\\Program Files (x86)\\Razer\\ChromaBroadcast\\bin': 3,
     'C:\\Program Files\\Razer\\ChromaBroadcast\\bin': 3,
     'C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath': 3,
     'C:\\Program Files (x86)\\Razer Chroma SDK\\bin': 3,
     'C:\\Program Files\\Razer Chroma SDK\\bin': 3,
     'C:\\ProgramData\\Oracle\\Java\\javapath': 3,
     'C:\\Windows\\system32': 2,
     'C:\\Windows': 2,
     'C:\\Windows\\System32\\Wbem': 2,
     'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\': 2,
     'C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common': 2,
     'C:\\Users\\yiyan\\AppData\\Local\\Microsoft\\WindowsApps': 2,
     'C:\\WINDOWS\\System32\\OpenSSH\\': 2,
     'C:\\Program Files\\NVIDIA Corporation\\NVIDIA NvDLISR': 2,
     'C:\\W': 1})

The %path is used to lookup a file if it does not exist inside your current directory (simplified) - having the same directory in it multiple times makes no sense whatsoever.

If a executeable would be in a dir - it would have beed found using the first entry in your %path - no need to look again 6 folders later.

After cleaning up your dupes, add the python folder to your path.

Patrick Artner
  • 50,409
  • 9
  • 43
  • 69
  • Other than cleaning up my path, is there anything else wrong with it? I was expecting only C:\Python34\Scripts to output when I inputted echo %PATH% – teleluck Mar 24 '19 at 10:17
  • @teleluck %PATH% is a windows variable that holds the complete paths to search stuff if it is not in your current dir- you should **not** have only `C:\Python34\Scripts` in it. See https://en.wikipedia.org/wiki/PATH_(variable) Before editing it - be sure you know what you do there... – Patrick Artner Mar 24 '19 at 10:18
  • @tele this might help you out as well: [SO: how-to-add-to-the-pythonpath-in-windows](https://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows) – Patrick Artner Mar 24 '19 at 10:25
  • Thank you so much! I cleared up my local PATH and now understand what %PATH% does now. – teleluck Mar 24 '19 at 11:02
0

I think the console command being 'py' and not 'python' anymore is post Python 3.8. I had Python 3.7 up until a few days ago and got confused when I updated too.

-1

typ this in cmd:

copy py.exe python.exe

in the map:

C:\Windows\system32

to go to there typ:

cd C:\Windows\system32

in cmd

Matthijs990
  • 637
  • 3
  • 26
  • That looks like very **unsafe** advice. – Patrick Artner Mar 24 '19 at 10:02
  • What "works" is not always safe. Do you know which version `py.exe` is? What if you update python and replace the current `C:\Python34` with a newer `C:\Python37` ? if you use the `py.exe` from C:\Windows\system32 by your suggested solution, this change will not be picked up. If you change the content of your %PATH% to include `C:\Python37` instead of `C:\Python34` this will be picked up. etc – Patrick Artner Mar 24 '19 at 10:22
  • why it is not save? – Matthijs990 Mar 24 '19 at 10:48