Installing Leo — Leo 6.8.4 documentation

# Installing Leo

This chapter tells how to install and run Leo on Windows, Linux and MacOS.

The short summary:

1. Install Python 3.9 or later, including pip.

2. Install Leo (including all of Leo’s dependencies) from either from PyPi or GitHub:

   - From PyPi:

         pip install leo

   - From GitHub:

         git clone https://github.com/leo-editor/leo-editor.git
         cd leo-editor
         pip install -r requirements.txt

If you have any problems installing Leo, please ask for help on Leo’s help forum.

## Installing Leo from PyPi

The following will install Leo from PyPi, Python’s package repository.

1. Install Python 3.9 or above.

2. Install pip.

3. Download and install Leo (including all required packages):

       python -m pip install leo

## Installing Leo from GitHub

The following will install Leo from Leo’s GitHub repository.

1. Install Python 3.9 or above.

2. Install pip.

3. Install Git.

4. Clone Leo’s repository:

       git clone https://github.com/leo-editor/leo-editor.git

5. Install Leo’s dependencies from Leo’s requirements.txt file:

       cd leo-editor
       python -m pip install -r requirements.txt

Note for Ubuntu

After installing on Ubuntu you may get this error messages when attempting to run Leo:

    qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.

To install the missing library run:

    sudo apt install libxcb-cursor0

## Installing everything with Anaconda or Miniconda

The Anaconda scientific computing environment includes Python, NumPy, SciPy, PyQt, and over a thousand other tools, packages and libraries. It’s a 500+ MB download but you’re guaranteed to have everything needed.

The Miniconda environment includes just Python and the conda package management tool. Pick and choose from the full Anaconda ecosystem.

Preparation, create an environment for Leo, activate it, and then install python:

    conda create -n leo
    conda activate leo
    conda install python

Strictly speaking this step can be skipped and Leo installed in the conda _base_ environment. The conda developers generally advise against installing in _base_ unless this program is the only thing the machine will be used for.

To install Leo run this from a console:

    pip install leo

## Installing Leo on MacOs 10.7 (Lion) and later

Many thanks to Ludwig Schwardt for the following installation instructions. Using the HomeBrew installation method is much easier than before.

Note from EKR: When upgrading MacOS, it’s probably a good idea to uninstall pyqt, sip and qt first:

    brew remove pyqt sip qt
    brew install qt sip pyqt

I (Ludwig) recently received a new MacBook Pro and did a fresh upgrade to Mac OS 10.7 (Lion). I then used the opportunity to test out installation procedures of various software on a clean system. My main finding is that the excellent Homebrew (mxcl.github.com/homebrew/) makes things much easier these days.

Why Homebrew? It does not try to replace every single bit of functionality on your Mac with their own version, like Macports or fink. It reuses the existing libraries as far as possible. No need to reinstall Python, for example (one of my pet gripes when people try to install new software on their Macs, and the source of much confusion and pain). It installs to /usr/local, the standard place to find third-party libraries and headers, instead of the obscure /opt or /sw. It’s simple to use and to extend.

Here is my installation write-up:

- Read the Homebrew installation instructions at https://brew.sh/.

- Make sure you have Xcode installed (test it by confirming that “gcc” runs in the Terminal) Only the smaller command-line tools are required; there is no need to get the full Xcode beast.

- In preparation for Homebrew, the best option in my opinion is to delete /usr/local via:

      sudo rm -rf /usr/local

  and install any software in it via HomeBrew instead.

  The HomeBrew package manager is so easy to use that you will find replacing deleted packages a snap.

  If deleting /usr/local fills you with dread (you do not want to lose your beloved third-party software), the second-best option is to make sure you have write permission for the directory via:

      sudo chown -R <your user name>:admin /usr/local

  If you don’t know your username, run “whoami”. :-) This is useful because homebrew actually discourages you from installing third-party software as the superuser (the usual Mac apps in /Applications are also installed as the normal user, for that matter).

- Install Homebrew. See the instructions at https://brew.sh/.

- Run “brew doctor” and check any further suggestions to improve your system.

  EKR note: I thought I had installed command-line tools after installing the XCode page. I hadn’t, and “brew doctor” told me so.

- Run “brew update” to get the latest formulas

- Install sip and note the caveat:

      brew install sip

  This warns you to add the local python directory to your PYTHONPATH. Make a note of what this is (especially if you are not on Lion!).

- Add the following lines to your ~/.bash_profile (or ~/.profile on Leopard). This is the default for LION:

      export PATH=/usr/local/bin:$PATH
      # This is for SIP (and PyQt) as suggested by Homebrew
      export PYTHONPATH=/usr/local/lib/python3.9/site-packages:$PYTHONPATH

- Install PyQt:

      brew install pyqt

- Open a new Terminal tab / window so that the above settings take effect, and install Leo. I downloaded the Leo-4.9-final-a.zip, unzipped it, and ran “python launchLeo.py” inside the Leo directory.

It would really be great to get a Leo formula going for Homebrew. As mentioned before, the main question is just where to place all the Leo files in the /usr/local hierarchy.