C

Command Line

Having some familiarity with the command line can go a very long way. My main suggestion is to go through the Software-Carpentry Unix Shell lesson.1 The “Navigating Files and Directories” episode (i.e., lesson) is probably the most important lesson there for this book, but learning about “Shell Scripts” is also important when you are running your Python code from the command line.

1. https://swcarpentry.github.io/shell-novice/

Since this book is mainly a Python book about Pandas, I won’t be able to go over all of the topics in learning the Unix Shell. The main takeaway I want to convey in this appendix is the notion of a “working directory”.

C.1 Installation

Likely, if you are on a Mac or Linux system, you will already have access to the Bash Shell. By default, Windows does not have it installed.

C.1.1 Windows

In Windows, the best installation approach is to follow the Software-Carpentry Bash Shell instructions.2 You will be installing Git for Windows,3 which will also provide the Bash Shell.

2. https://carpentries.github.io/workshop-template/#shell

3. https://gitforwindows.org/

If you do not want to use Git for Windows, Anaconda also comes with its own Anaconda Prompt that you can use to run Python code from the command line. The only difference here is that the Anaconda Prompt will use Windows command line commands, instead of the UNIX-like ones on a Mac or Linux system. However, running your Python scripts from the command line will be the same.

C.1.2 Mac

You can find the Terminal application in Applications / Utilities. That is, in your main application folder, there will be a folder called Utilities, where you can find the Terminal.

iTerm2 is a popular alternative to the default Mac Terminal application.4

4. https://iterm2.com/

C.1.3 Linux

The terminal and bash are set up on Linux systems by default.

C.2 Basics

At minimum, you should know the following commands:

  • Where you currently are in your file system (Windows, Mac, Linux: pwd)

  • List the contents of the current folder you are in (Windows: dir, Mac, Linux: ls)

  • Change to a different folder (: cd <folder name>)

  • Run a Python script (Windows, Mac, Linux: python <python script>.py)

Another useful “command” is .. (two dots), which refers to the parent folder of where you are now (Windows, Mac, Linux: pwd).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.218.69