How To Run Python Script Without Python Installed
This post is part of the complete Guide on Python for SEO
Integrated Development Environment'south like VSCode are super useful considering they take care of most of the difficulties around programming. Simply, what if you don't want to utilise an IDE to work with Python, but use command-line instead?
I will bear witness you how you can create and run a Python script using the control-line but.
If you don't know what is the control-line, this post is probably too avant-garde for you. Just read the complete guide on Python for SEO.
Getting Started
Open the Last.
Showtime, brand sure that you take Python installed on your computer.
If Python is installed, yous'll accept something like this:
Write Simple Code Using the Python Interpreter
If you just want to write simple lawmaking like print('Hello world!'), you tin utilize the python interpreter by typing python in the Terminal.
The python interpreter lets you lot write and execute code line by line.
As you write more complex lawmaking, you lot will want to pre-write your code in .py files. To do this without leaving the Concluding, you volition need to use the vim editor to pre-write them.
Create the Python File
We will use vim to create a new Python file. Vim is a text editor that yous can use from the control-line.
This will open up the vim editor.
Vi Editor Commands
Offset, let's wait at the commands you tin use in the vi editor.
| i | Switch to Insert mode (editing style) |
| esc | Exit the editing mode |
| dd | Delete the electric current line |
| u | Disengage the concluding change |
| :q! | Shut the editor without saving changes. |
| :wq | Salve the text and close the editor |
→ + Shift | Movement Cursor Faster |
| $ | Move to end of line |
Write Your Python Script
To write in the vim editor, press i to switch to insert mode.
Write the best python script in the world.
Press esc to leave the editing mode.
Write the command:wqto save and quite the vim editor (w for write and q for quit).
Run Your Script
Run your script by typing python hello.py in the Last.
Congratulations, yous at present know how to create and run a Python script using the Command-line.
Sr SEO Specialist at Seek (Melbourne, Australia). Specialized in technical SEO. In a quest to programmatic SEO for large organizations through the utilize of Python, R and machine learning.
Source: https://www.jcchouinard.com/create-python-script-from-terminal/
Posted by: willardwhavence.blogspot.com

0 Response to "How To Run Python Script Without Python Installed"
Post a Comment