Below are instructions regarding installing things needed for general development with Python3 (including two example libraries). They include:
- Xcode (Command Line Tools)
- Homebrew
- Python3
- PyPI
- Jupyter
- BeautifulSoup4
- Natural Language Toolkit
Do you have Xcode? To check go to the terminal and execute xcode-select -p
.
- If
/Applications/Xcode.app/Contents/Developer
(or something similar) appears as a response proceed to the next step. - If anything else happens download and install
Xcode
from here before moving on.
Enter xcode-select --install
into the terminal, which should result in something like this:
Click Install
to download and install the Xcode Command Line Tools (it takes a while so maybe go make some food or get a cup of coffee or something).
Copy and paste this code into the terminal and press enter
to install homebrew: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
If prompted, agree to the Xcode license
by executing sudo xcodebuild -license
in the terminal.
Search to see if something is available on homebrew
with search
. For example: brew search python3
To install Python3 execute brew install python3
in the terminal.
PyPi is frequently referred to as pip
. It is used to manage Python library installations and ships with Python3 when installed via Homebrew. The command to use it is pip3
, not pip
.
Search for something on pip3
with the search
command. For example: pip3 search jupyter
Install Jupyter via pip3
as follows:
pip3 install --upgrade pip
pip3 install jupyter
Executing jupyter notebook
in the terminal starts the IDE.
On the Jupyter homepage click New
and select Python3. This will create and open an iPython Notebook file.
Click File
, select Save As
and then name the file. Next click File
and select Close and Halt
to exit.
When you return to the Jupyter homepage you should see the iPython Notebook file (.ipynb
) that you just saved.
pip3 install beautifulsoup4
pip3 install lxml
sudo pip3 install -U nltk
Confirm that it works with the following steps (all in the terminal):
ipython3
import nltk
nltk.
and then hit theTAB
key on your keyboard
Run Jupyter, navigate to the file you created earlier, import the NLTK library, then run the downloader in the following steps:
jupyter notebook
- Navigate to the file, open it
import nltk
nltk.download()
A new terminal window will open that looks like the image below. Select book
and click Download
: