Solutions for common Python and commandline issues
Common issue: in the commandline, running
python --versionreturns 2.7.6, or one of the other 2.7 versions. This is happening because the default version of python is 2.7, even if you have 3.4 installed. One solution is to run
python3 --versioninstead, which hopefully should return 3.4.3, or one of the other 3.4 versions. To create a short-term solution, on Linux or Mac, you can run:
alias python=python3However, this will only work for the current terminal instance. If you open up a new terminal later on, you'll have to type this again. To create a long-term solution, run:
cd ~This will first bring you to your home directory, then open up the file .bash_profile. At the end of this file, add the line:
alias python=python3Then save the file (CTRL-x CTRL-s) and exit emacs (CTRL-x CTRL-c). This will make the change to Python 3.4 permanent.
If you are using a Windows machine, you make have gotten the following error when typing "python" into the commandline (cmd):
'python' is not recognized as an internal or external command, operable program or batch file.This is happening because, by default, the folder containing python is not added to your path. One solution is to navigate to where python is located and work from there, but this is not a great long-term solution. One solution is instead of typing "python" each time, type the full path, i.e.:
c:\Python34\python --versionA better solution is to add the location of python to you PATH variable, as described below. These instructions are from this stack overflow question , which also contains several other workarounds if this doesn't work for you.
One reason we're using the commandline in this class is that it's a great life skill! Usually we use a graphical user interface (GUI) to navigate between folders, to create, edit, and delete files, and to execute programs. But almost all of this we can do through the commandline. Here are a few tips for getting started.
cd Documents/To see what folders are available in your current directory, type "cd", then a space, then hit the tab key a few times. Also, once you start typing a folder name, hit tab anytime to auto-complete the name (or see what other folders match so far). To move up a folder, run