A riskier option is to create a symlink:
sudo ln -s /usr/bin/python /usr/bin/python3
This is a risky choice because any system update can clog the symlink. If the system still has Python 2 installed, it will only be replaced with the Python 2 executable. This can affect all scripts on the system.
Once you've set up the Python interpreter, you can start launching it. Directly typing in code and seeing what happens is a great way to learn about how Python works.
The way the compiler works is very simple. Like the shell, you will see a prompt for input. After pressing Enter, the Python interpreter will evaluate the code and return the result. You will receive an error message or the result of certain operations.
Basically, we usually get the standard 'Hello, world!' message. on the screen.
The code that does this in Python is pretty simple:
print("Hello, world!")
When you're done with the interpreter, press Ctrl + D or type 'exit()' to return to the shell prompt.
Writing Python scripts in WSL is also simple. All you have to do is invoke the interpreter with the appropriate shebang line at the top of each script:
#!/usr/bin/env python
This action calls the env program to run Python whenever it is installed on the system. This is important because Python can be installed in other categories, depending on the distribution or operating system.
You also need to make sure the script has execute permissions:
chmod +x script.py
To run the script, call it using the command line in the saved directory, prefixing it with ' ./ ' in front:
./script.py
Python on WSL provides an easy way to get started with cross-platform application development. Hope the above guide is useful to you.