2

I work on an api that run python3 scripts like python3 <scriptname.py>. This api initially run on a linux system. Unfortunately I make the local development of it on a windows. Is there a way to simulate this behaviour so that when I run in powershell python3 -V it give me the version of python.

I have allready python 3 installed on my computer. I tried to add the path to my python.exe to the system variables with for variable the string python3. But after registering and restarting powershell and type python3 -V I still get the error that «python3» is not recognized as a command applet name.

Does anyone have any ideas?

johannchopin
  • 13,720
  • 10
  • 55
  • 101

2 Answers2

4

Once python is in your path, you can define a PowerShell alias for python3.

PS > New-Alias python3 python
PS > python3 -V
python 3.6.5

In order to have this alias as a permanent one, refer to this question: Permanent PowerShell Aliases.

yakobyd
  • 572
  • 4
  • 12
0

I found tricky solution.
Once python is in your path, go to python installed path and copy python.exe and named duplicated one as python3.exe

enter image description here

Slava Rozhnev
  • 9,510
  • 6
  • 23
  • 39
HODONG
  • 13
  • 4
  • Thanks for posting a solution but this is really a tricky one :) I definitively recommend [yakobyd](https://stackoverflow.com/users/9919541/yakobyd)'s answer. – johannchopin Jul 15 '21 at 08:08