install motioneye on raspberry pi

How to Install MotionEye on Raspberry Pi (Video Surveillance)

MotionEye is a web interface for the Motion service, which is commonly used on Raspberry Pi to connect, manage, and monitor all kinds of cameras. It’s not directly available in the official Raspberry Pi OS repository, so I’ll guide you through the process of installing everything on your Pi in this step-by-step tutorial.

MotionEye can be installed on any Linux distribution by using PIP (the Python package manager). All the dependencies, including Motion and a web server, will be automatically added to the system.

I’ll start with the prerequisites (hardware and software), and then I’ll give you all the commands to install it on your Raspberry Pi in a few minutes.

If you’re looking to quickly progress on Raspberry Pi, you can check out my e-book here. It’s a 30-day challenge where you learn one new thing every day until you become a Raspberry Pi expert. The first third of the book teaches you the basics, but the following chapters include projects you can try on your own.

Prerequisites to run MotionEye on Raspberry Pi

MotionEye can be used in many ways, but here are my recommendations to get started properly with it on Raspberry Pi.

Hardware requirements

  • Any Raspberry Pi model: I’m testing this on my Raspberry Pi 4, but it doesn’t really matter. The services are light enough to run on any model and they are all supported.
    A Raspberry Pi Zero 2W could be a good fit if you plan to plug a camera directly into it (small and discreet but powerful enough).
  • SD card or USB stick for the system: we’ll use Raspberry Pi OS, so both are supported. I tested with my standard SanDisk USB key.
    You may need an additional drive if you plan to record the camera flow, or add movement detection later on (this would be my go-to drive for this, same as your Pi with tons of disk space).
  • Keyboard and mouse (optional): I’m using my new favorite Rii keyboard for all my projects now. But you can use a headless setup and follow this tutorial from your computer if you prefer.

A camera module is optional. You can use motion eye in two main ways:

  • As the control center just for the web interface. You’ll connect it to various IP cameras, or another Raspberry Pi (running Motion or MotionEye themselves if needed).
  • As a standalone security camera, with only one device. In this case, you’ll need a camera module on the same Pi as MotionEye.

I recommend using the official camera module for this (or the NoIR alternative). They are perfectly supported by Raspberry Pi OS and MotionEye, so it would be the easiest way.

Operating system

MotionEye relies on Python, so it should work on any operating system as soon as you have Python 3 available (and installed).

If you can, go with Raspberry Pi OS. I tested with two versions and I can confirm it’s working, so you’ll avoid any potential issues due to the operating system. But you’re welcome to test with something else if you already have another OS running.

If you do the installation for a dedicated project, the lite version of Raspberry Pi is enough, you don’t need a desktop environment. I discovered while doing these tests for you that, even on RPI OS Lite, you get a preview of the camera picture on your screen when you test it with libcamera-still (so even for debug purposes there’s no need to install a desktop environment).

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now

If you plan to plug a camera into this system, I would recommend using the Legacy version of Raspberry Pi OS. The new OS version came with many changes in its camera management, and I had some issues making it work on the latest version.

If you need some guidance to install Raspberry Pi OS, you can click on this link to follow my tutorial. Get your system set up with network access and move on.

Note: There is a MotionEyeOS image available somewhere, but it hasn’t been updated for several years. I’m not using it because it’s probably safer to start with Raspberry Pi OS and install the application on it “manually”.

Optional: Camera installation

MotionEye can connect to any kind of camera, local camera (USB, camera module, …), or any model on your network (or even remote cameras). Once the interface is installed, you can add as many cameras as you want.

Join Our Community!

Connect, learn, and grow with other Raspberry Pi enthusiasts. Support RaspberryTips and enjoy an ad-free reading experience. Get exclusive monthly video tutorials and many other benefits.

Learn more

But if you plan to use a Raspberry Pi camera module on it, please do the installation and tests before going further. There’s no point in following all the steps for MotionEye if the camera doesn’t work already.

I have a dedicated tutorial on this website on how to install a camera module on Raspberry Pi. Read it for more details.

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now

MotionEye installation guide

Here are the main steps to install MotionEye on your Raspberry Pi:

  • Make sure your system is up-to-date.
  • Install all Python dependencies and the PIP package manager.
  • Use PIP to download and install MotionEye from the GitHub project.

Let’s see all these steps in detail now.

Update your system

As always, it’s good practice to update your system before starting any package installation for a new project. You can do this with two commands:
sudo apt update
sudo apt upgrade -y

You can type them directly on the Raspberry Pi, or do it like me, and use SSH to do everything from the comfort of your computer (here is my SSH guide if you need help to set this up).

Are you a bit lost in the Linux command line? Check this article first for the most important commands to remember and a free downloadable cheat sheet so you can have the commands at your fingertips.

Install MotionEye dependencies

We can then move on and install the required dependencies for MotionEye:
sudo apt install python3-dev libcurl4-openssl-dev libssl-dev

On Raspberry Pi OS, Python 3 is preinstalled (on all versions), so it should be pretty quick. But if you use another distribution, there will probably be way more packages to install at this stage.

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now

We also need PIP (Python package manager), so make sure it’s installed by using this command:
sudo apt install python3-pip

Note: When testing with Raspberry Pi OS Buster (Legacy), I got some errors during the MotionEye installation that got fixed by doing this first:
sudo python3 -m pip install -U pip
I didn’t need that on Bullseye, but if you experience any issues you can do it, it’s safe (for information, the error I got was “Command “python egg_info” failed with error code 1″).

Install MotionEye

Now that the dependencies are installed, we can use the main commands to install MotionEye. We’ll download the archive from their GitHub project directly. So feel free to click on the link if you want to take a look first.

Anyway, here’s the command to install it with PIP:
sudo pip3 install ''

Once done, we can run the MotionEye initialization script, which will add all the requirements (including Motion, MariaDB, a web server, etc.):
sudo motioneye_init

I only tested on a brand-new Raspberry Pi OS setup, so I can’t tell you how well it’s integrated if you already have some of these services running. I guess it will ask for your MySQL password at some point, but I don’t know. Maybe it’s safer to do a backup first in this case.

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now

🛠 This tutorial doesn't work anymore? Report the issue here, so that I can update it!

Want to chat with other Raspberry Pi enthusiasts? Join the community, share your current projects and ask for help directly in the forums.

Getting started with MotionEye

Once MotionEye is installed, it’s ready to use. The web interface starts automatically, so you can directly use it to add new cameras to your system. Here are a few tips to get started.

Web access and configuration

The MotionEye interface is accessible via a web browser, on the Raspberry Pi IP address with the port 8765: http://<YOUR-IP>:8765.

If you don’t know the Raspberry Pi IP address, you can use one of the ways listed here to find it quickly. If you have a desktop environment, http://localhost:8765 should work too.

The default page of MotionEye gives you a login form. The default credentials are:

  • Login: admin
  • Password: (empty)

Click on “Login” to access the full interface.

Start the service

MotionEye and Motion services are set to start automatically after the installation, so you shouldn’t have to worry about them.

If needed, you can handle them with your favorite service management command. I generally use service for this:
sudo service <service_name> status | start | restart | stop
But “systemctl” should work too.

So, for example:
sudo service motioneye status

Adding your camera

Once connected to the web interface, you’ll be invited to add your camera to it.

From there, the next steps will be completely different depending on your project. If you only want to add the camera module from the Raspberry Pi, choose “Local MMAL Camera” and pick the one suggested in the camera list:

If everything works as expected, you should get an interface looking like this:

You have a preview of your camera on the right side, and many options on the left. You can add as many cameras as you like by clicking on the dropdown list (Camera1) and then “Add new camera…”.

As mentioned earlier, MotionEye supports the Pi camera module (works best on Buster), but you can add any remote camera to the same page, and view all your security cameras from one page.

From there, I’ll let you play with all the options and check the official wiki for specific questions.

To push your project a bit further, I would probably add a VPN server on the Raspberry Pi, so you can access the MotionEye page from anywhere. In this case, just don’t forget to set a strong password (Admin without a password is not a good idea ^^).

Whenever you’re ready, here are other ways I can help you:

The RaspberryTips Community: If you want to hang out with me and other Raspberry Pi fans, you can join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.

Master your Raspberry Pi in 30 days: If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiple projects with step-by-step guides.

The Raspberry Pi Bootcamp: Understand everything about the Raspberry Pi, stop searching for help all the time, and finally enjoy completing your projects.

Master Python on Raspberry Pi: Create, understand, and improve any Python script for your Raspberry Pi. Learn the essentials step-by-step without losing time understanding useless concepts.

You can also find all my recommendations for tools and hardware on this page.

Similar Posts