Wednesday, April 15, 2015

Mac OS X Terminal Commands - Getting Started - Python Tutorial

Mac OS X Terminal CommandsWhen it comes to learning Python there are several other tools you will need to learn as well to make you full fledge Python programmer. In today’s tutorial we will focus on Mac OS X Terminal Commands which we will need to know since we will spend a good amount of time in the Terminal.  Some of you that were around when computers only took commands from command line maybe thinking why are we going back in history but the truth is if you are familiar with the terminal you will be able to make things happen faster and easier than the graphical interface will allow you.


What Is The Terminal?


The terminal is an application that gives you ability to command your computer to perform a certain task by typing in a short command. When using the terminal, you are giving your computer a direct command similar to what some software would do if you were using software to perform the task. The terminal application is the same as back in the day when you would have to type in the command line for certain commands to put a game on your computer or to get the computer to do a simple task. The reason why the terminal is still available in the graphical user interface era is because it is one of the most powerful tools your computer has.


How to Open The Terminal?


The terminal application is located in the applications folder > utilities > terminal. We can either open the terminal through finder or we can be quicker or lazier however you want to look at and press command + space bar which opens spotlight and then we can type in the terminal.


How to Open The Terminal?
Command + Spacebar then type terminal

 


I suggest that you then pin your terminal to your dock so we can be even lazier and just click on the terminal as we go through our Python tutorials.


Entering The Terminal


Now that we have the terminal open.  You will not see much but your terminal will look a bit different than mine.


Open Terminal


Our commands start after the $ symbol.  In this tutorial, we are going show you the $ symbol in our examples since that symbol is universal but do not type it into your terminal when following along with us. Let’s get started with some basic Mac OS X terminal commands that we will be using in our Python tutorials.


Print Working Directory


pwd – Print working directory gives the location of the directory we are currently in.  This is a good way to find out where you are currently at within your files.


$ pwd
/Users/Tommy/desktop

List Information About File


ls – List information about file gives us all the files and folders in the containing folder.


$ ls
comments.py python wizardtut.py
django videos
projects web developement notes

Change Directory


cd – Change directory gives us the ability to navigate through our folders and files.


$ ls
Applications Downloads Pictures
Creative Cloud Files Library Public
Desktop Movies
Documents Music

Thomass-MBP:~ Tommy$ cd desktop

Thomass-MBP:desktop Tommy$

cd /foldername/filename – Move multiple directories at once.


$ cd desktop/python
Thomass-MBP:python Tommy$

cd .. – Move up to parent directory


python Tommy$ cd ..
Thomass-MBP:desktop Tommy$

cd ../.. – Move up to directories


Thomass-MBP:python Tommy$ cd ../..
Thomass-MBP:~ Tommy$

Create New Folder


mkdir – We can create a new folder using this command.


Thomass-MBP:desktop Tommy$ mkdir learnPython
Thomass-MBP:desktop Tommy$ cd learnPython
Thomass-MBP:learnPython Tommy$

Create File


touch – We can use this command to create a file


Thomass-MBP:desktop Tommy$ touch manage.py
Thomass-MBP:desktop Tommy$ ls
django projects web developement notes
learnPython python wizardtut.py
manage.py videos

Remove Files


rm – This command gives us the ability to remove files


Thomass-MBP:desktop Tommy$ ls
comments.py projects web developement notes
django python wizardtut.py
learnPython videos
Thomass-MBP:desktop Tommy$ rm comments.py
Thomass-MBP:desktop Tommy$ ls
django python wizardtut.py
learnPython videos
projects web developement notes
Thomass-MBP:desktop Tommy$

Remove Folder


rmdir – This command gives the ability to remove folders


Thomass-MBP:desktop Tommy$ ls
django python web developement notes
learnPython test wizardtut.py
projects videos
Thomass-MBP:desktop Tommy$ rmdir test
Thomass-MBP:desktop Tommy$ ls
django python wizardtut.py
learnPython videos
projects web developement notes

Make Computer Talk


say – This will change your text into audio.  This has nothing to do with our Python tutorials but I think it is fun and wanted to share it.


Thomass-MBP:desktop Tommy$ say "Learn Python Tutorial is the best Tutorial Site"

Conclusion of Mac OS X Terminal Commands


Now that we have covered some of the basic Mac OS X Terminal Commands we can move on with our Python tutorials.  Theses are only the basics if you want to learn more there are several resources on the internet do not forget to check them out. The commands that we covered in this tutorial will help you through the Python tutorials and if any others come up during the tutorials I will remember to share them.



Install Python 3 on Windows - Getting Started - Python Tutorial

Install Python 3 on WindowsIn this tutorial, we are going to look at how to install Python 3 on a Windows operating system. Unlike Mac, Windows has no default Python software installed on its computers. When we install Python on the Windows computer this will be the only Python available. I apologize that I do not have screenshots but for some reason my wife’s laptop will not take screen shots so if you need more help check out our video tutorial.


Download Python 3


Step 1 – Visit http://python.org this is the primary site for the Python Programming Language. If this is the first time you have visited the Python website after you’re done with this tutorial I suggest that you cruise their website. They have so much great information.


Step 2 – On the main menu hover over Downloads on the right side of the drop down click on Python 3.4.X. X will be a number currently at this time of this tutorial the current version is Python 3.4.2. As long as you click on Python 3 you are ready to go. Download will begin.


Install Python 3 on Windows


Step 1 – Locate your download.  Most likely in your downloads folder or if you use Google chrome it will be on the bottom of the browser.


Step 2 – Open File – Security Warning may open click on the run button.


Step 3 – Select whether to set up Python 3.4.X for all users on this computer.  Your choice here how you wish to install the software for all users or just for you. Then click next.


Step 4 – The Select Destination Directory I suggest that you leave it as current unless you know what you are doing. Then click next. If you change the location Python may not work on your computer.


Step 5 – Customize Python 3.4.X. Leave everything as is but scroll down to “Add python.exe to Path” click on the button and select “Entire feature will be installed on local hard drive” then click next.


Step 6 – The installation process will start. You may get a message “Do you want to allow the following program to install software on your computer” click yes.


Step 7 – You will see a screen that says Complete Python 3.4.X Installer click finish.


Test The Installation


Step 1 – Click on the start button on the bottom left hand corner


Step 2 – In the search type cmd this opens command prompt on Windows and hit enter


Step 3 – When your command prompt opens type “python” no quotes.


You should see the following in your command prompt.


C:\python
Python 3.4.2 (v3.4.2:ab2c023a9432)
Type "help", "copyright", "credits" or "license" for more information.
>>>

Yours should look similar to this. Please take notice of the Python 3.4.2 and below that >>> this means you’re in the interpreter.


If you get an error here please refer to the above video I will describe how to fix the issue. Try restarting your computer and if that doesn’t work the usual suspect when it comes to Python and Windows is the path and I will describe how to access your variables in your path and make the need changes.


Step 4 – Exit the interpreter using exit() or quit()


Awesome you have install Python 3 on your Windows computer.


Windows users for these tutorials I use a Mac so there is a couple differences I want you to be aware of.


  • When I say terminal that means Command Prompt to you

  • When I say open Python interpreter using python3 and means you use Python

  • When I say exit the interpreter using control + d that will not work for windows so will need to use exit() or quit() exit interpreter.

Other than those few issues above there really is no other differences. If you come across one please let us know since we use Macs here, but we want you Windows users to be able to follow a long as well.



Tuesday, April 14, 2015

Interpreter - Python Tutorial


An interpreter is a program that executes instructions which are normally in a coding language and are given by the user or by another program that has not been compiled into machine language yet.



Terminal - Python Tutorial

terminalThe terminal is a program that is included on the Mac OS X. The terminal provides a line interface that controls the UNIX based operating system. When using Python on a Mac we access the terminal very often to make commands to the Python software. 


To access the terminal on a Mac:


Via Spotlight – command + spacebar or click on magnifying class at the top screen to open spotlight. Once spotlight is open then type “terminal” to open the application.


Via Finder – applications > utilities > then terminal



Monday, April 13, 2015

Install Python 3 On Mac OS X - Getting Started - Python Tutorial

Install Python 3 On Mac OS XBefore we can get started with our Python tutorials we need to install Python 3 on Mac OS X. Python comes as a software package available for the Mac operating system and installation is pretty straight forward. Python 2.7 is already on your Mac but in this tutorial series, we are focusing on Python 3 since this version of Python is not installed we need to install it on the Mac. Follow this tutorial step by step when setting up Python 3.


Find Python 2 First


I would like you to find Python 2 first.  We are only doing that to show you how to access Python 2 in your system. You will do almost the same steps to access version 3.  You may also want to find out how access version 2.7 in future to work in this version. Do not delete the default version on your computer this will cause all types of problems since some of the Mac’s default software uses version 2.7 to run applications.


Step 1 – Access Your Terminal


We will be doing a lot work in terminal throughout this tutorial series so this is an important step. To access the terminal on a Mac you have several options.


Via Spotlight – We can find the terminal via the spotlight option on the Mac to do this push command + space bar at the same time or go to top of your screen and click on magnifying glass.


mac spot light
Mac Spotlight

Now that we have the spotlight open now we simply type in “terminal”.


spotlight with terminal


Simply hit enter and your terminal will open.


Mac Terminal


There you go there is your terminal.  Your terminal may seem sort of different. That is all right as long as we got it open.


Via the finder – Now opening the terminal via the finder takes longer, but it’s good to know where it is located in your finder. Open finder > applications > Utilities > Terminal. There you go the terminal is open but easier to open via spotlight using command + space bar.


Optional Add Terminal to Dock – I add the terminal to the dock since I use it everyday this is optional for you, but if you are going to follow a long in this tutorial I suggest adding the terminal to your dock. To add the terminal to your dock right click terminal in the dock then go to options > click keep in dock.


Step 2 – Access Python 2


Now that we have the terminal open let’s access Python 2 we do this by simple typing “python” into the terminal and pressing the return key.


#Your layout may look different especially before the dollar sign 

Thomass-MBP:~ Tommy$

#Now enter "python"

Thomass-MBP:~ Tommy$ python

#Hit enter

#Now you should see something similar to this
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

#If you see this then you have accessed Python Interpreter

If you did not get your Python 2 interpreter open then please let us know via the comments below or answers section in the main menu.  We can look into why you were not able to access your Python 2 interpreter. Now that you were able to access the Python 2 interpreter lets exit the interpreter by typing quit() or exit() or control + d. When you exit your terminal should not show >>> that is how you know you have properly exited the interpreter.


Install Python 3 On Mac OS X


We can now install Python 3 on Mac OS X.  Please follow the steps exactly, so we do not have any issues installing Python 3.


Step 1 – Visit http://python.org this is where we can download the Python 3 software.


Step 1 - visit http://python.org
Step 1 – Visit http://python.org

 


 Step 2 – Hover over downloads on Python.org home page.


Hover over downloads on Python.org
Hover over downloads on Python.org

Step 3 – Click on Python 3.4.2 button and Python 3 will download


Click on Python 3.4.2 and Python 3 will Download
Click on Python 3.4.2 and Python 3 will Download

Step 4 – Just open the download where you have download the software. Yours maybe different than mine, but most likely in your downloads file. We will refer to the screenshot below and press continue.


Open Python Download
Open Python Download

 


Step 5 – Now we are on a screen that says important information. You can read this if you like if not then go ahead and press continue.


Important Information Page
Important Information Page

 


Step 6 – Now we are on a screen that says the software License Agreement. Once again you can read this if you like and when done click continue. Then a screen will pop up click agree if you agree with the Software License Agreement.Software License Agreement


Software License Agreement


 


Agree to Software License Agreement
Agree to Software License Agreement

 


Step 7 – Next page we come to is install location page. Do not change the location unless you understand what you are doing. Just press install to install in the current location.


Install Location
Install Location

Step 8 – When you press install a window will popup and ask you to enter your password please do so.


Enter Password
Enter Password

Step 9 – Python will start the install process.


Python will Start Install Process
Python will Start Install Process

 


Step 10 – When installation is complete press close button.


Installation Complete Press Close
Installation Complete Press Close

 


Now Python is installed on your computer. We will now check the installation to ensure that it installed properly. To check the installation of Python follow the next couple of steps.


Check Python 3 Installation


Step 1 – Open the terminal using the steps in the beginning of this tutorial.


Open Terminal
Open Terminal

Step 2 – Now we type “python3″ to open our Python 3 Interpreter and press Return.


Type "python3" Press Return
Type “python3″ Press Return

 


Step 3 – We should see something very similar to the following screenshot.


You Should See The Following
You Should See The Following

 


If you see something very similar to the above screenshot especially Python 3.4.X. X being the latest version so this may change just a bit. If you see this, then you have successfully complete the Install Python 3 on Mac OS X tutorial. If you did not get this or got some errors please leave a comment below or in the answers section of this website so we can help you get Python 3 on your Mac.


The install Python 3 on Mac OS X process is very simple but if your operating system is configured differently than we could run into some issues. If you have any questions about the installation process, please ask we are here to help you a long.



Python Software Foundation - Python Tutorial

Python Software FoundationThe Python Software Foundation is the non-profit organization in charge of developing Python. The Python Software Foundation was established in 2001 to support the Python Programming Language. You can visit the Python website http://python.org to get more information on the Python Software Foundation.



Sunday, April 12, 2015

Guido Van Rossum - Python Tutorial

guido van rossumGuido Van Rossum is a dutch computer programmer who developed the Python programming language. Mr. Van Rossum now oversees the development of Python.  He has been employed by Google where he spent most of time developing Python.  He now works for Dropbox.