Python is one of the most highly used programming languages out there.
It's easy to learn and is a highly useful language.
According to this website:
Python is one of the most used programming languages.
Technically it comes in fourth, but CSS isn't really a language, and JavaScript is mainly used for web development.
So, you have heard enough about python and want to get started? Well, here's how:
Downloading & Installing Python
First we need to install Python before we do any programming.
Linux
Installation on Linux is pretty straight-forward, most Linux OSes come with python installed so we need to check before we install anything.
To check this run one of these commands in the terminal:
python --version
python3 --version
In this tutorial we will be using Python 3 instead of Python 2.
This will tell you if you have python installed or not. If not (or if you have Python 2 installed), you need to install via the Linux terminal:
sudo apt-get install python3.7
(the python3.x will change in the future so feel free to look up the latest version of python available)
If you have both Python 3 and Python 2, install Python 3 and in the future use python3 myscript.py
to run your Python 3 scripts, and python myscript.py
for Python 2 scripts.
Windows
For Windows you will need to go to the Python website and download the installer.
Select the installer version appropriate for your Windows Architecture and install.
Mac OSX
Python is typically installed with later versions of OSX, if not please follow these instructions.
This is a little bit more complicated for Mac users.
1. To start off, we need to install XCode
(If you already have XCode, Command Line Tools, and Homebrew skip to step 4)
Just follow this URL to go to the XCode webpage for Mac:
Follow the instructions to install and then move on to step 2.
2. Now we need to install Command Line Tools
The Command Line Tools package gives OSX very useful command line tools (e.g clang, git, make, etc)
After you have installed XCode, use this command in the terminal to install Command Line Tools:
xcode-select --install
This will open up a dialog saying something about "xcode-select needing command line tools", and asking you if you want to install it. Just press install.
3. Installing Homebrew
Homebrew is a crucial dependency of any developer on Mac. It is a package manager (Linux think synaptic)
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
4. Installing Python
To install Python with Homebrew use this command:
brew install python
or
brew install python3
5. Installing PIP
PIP Is a Package installer special to Python. It is the only way to install Third-Party Python Packages.
To Install PIP just use these commands in the terminal
curl -O http://python-distribute.org/distribute_setup.py
python distribute_setup.py
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
python get-pip.py
There you have it! You now have Python installed on your OS of choice, to test this type this in and terminal or command line
python --version
Or
python3 --version
The Part 2 of this tutorial will include how to use Python, and basic commands and functions.
Very useful and informative post.