Installing Python dependencies
I recommend that you install Anaconda so that there are no issues with installing Python and using it for fastText. Detailed instructions for installing Anaconda are given on the official documentation page, which can be accessed at https://conda.io/docs/user-guide/install/linux.html. Simply stated, if you are on Windows, then download the Windows installer, double-click on it, and then follow the instructions on the screen. Installing it using a GUI is also possible for macOS.
In the case of Linux and macOS, download the corresponding bash file and then run the following command in a Terminal:
$ bash downloadedfile.sh
Please take care to download and install it using installers that are tagged for Python 3.x. The Python code snippets that will be shown in this book will be shown for Python 3.x.
Installing fastText on Windows
Currently, official binaries are not provided for fastText on Windows, and hence there is no GUI to install fastText on your machine. To use fastText, you will need to perform the following steps:
- Download the latest binary named fasttext-win64-latest-Release.zip from the release page provided by Xua (https://github.com/xiamx/fastText/releases).
- This is a ZIP file and hence you will need to extract the contents. You will find the
fasttext_pic.lib
,fasttext.lib
,fasttext.exe
, andfasttext.dll
files in the extracted folder. This folder will be your working directory for fastText:

- Create a folder,
data
where you will keep all your data files. Now, open PowerShell and change directory to the folder. - Type
.\fasttext.exe
in Powershell and you should be able to see the output.
If you don't see any output at the end, then you probably don't have Visual C++ Redistributable in your machine and will need to install that.
Installing fastText in Linux and macOS
To install fastText, run the following commands to clone the image and build it in a Terminal:
$ git clone https://github.com/facebookresearch/fastText.git $ cd fastText $ mkdir build && cd build && cmake .. $ make && make install
In this book, a lot of focus will be on building systems for Python. So, run the following commands as well in the same directory:
$ pip install .
pip
is the package manager for Python. fastText assumes UTF-8 encoded text, which is the default in Python 3.x. The Python code examples in this book will be shown using Python 3.x. One of the advantages of fastText is that you can build fastText models for multiple languages and if you are not using Python 3.x, then you will not be able to take advantage of this. If that is not a concern and you are trying to use fastText using Python 2.7, then take a look at the Appendix at the end, which will give you guidelines on how to develop, keeping in mind UTF-8 in Python 2.7.