Setting up OctoPrint on a Raspberry Pi running Raspberry Pi OS (Debian)

Well, I was able to get the webcamd service working. You were right about where to add the -d /dev/video1.

I also stripped out everything for the Raspberry pi in webcamDaemon.

MJPGSTREAMER_HOME=/usr/bin/
MJPGSTREAMER_INPUT_USB="input_uvc.so"

# init configuration
camera="auto"
camera_usb_options="-r 640x480 -f 30 -d /dev/video1"

# runs MJPG Streamer, using the provided input plugin + configuration
function runMjpgStreamer {
    input=$1
    pushd $MJPGSTREAMER_HOME
    echo Running ./mjpg_streamer -o "output_http.so -w ./www" -i "$input"
    LD_LIBRARY_PATH=/usr/lib/ ./mjpg_streamer -o "output_http.so -w ./www" -i "$input"
    popd
}

# starts up the USB webcam
function startUsb {
    logger "Starting USB webcam"
    runMjpgStreamer "$MJPGSTREAMER_INPUT_USB $camera_usb_options"
}

# echo configuration
echo camera: $camera
echo usb options: $camera_usb_options

# keep mjpg streamer running if some camera is attached
while true; do
    if [ -e "/dev/video1" ] && { [ "$camera" = "auto" ] || [ "$camera" = "usb" ] ; }; then
        startUsb
    fi

    sleep 120

done

I moved mjpg_streamer to /usr/bin/, input_uvc.so and output_http.so to /usr/lib/,
and webcamDaemon script to /usr/local/bin.

/etc/systemd/system/webcamd.service I changed to

[Unit]
Description=Camera streamer for OctoPrint
After=network-online.target OctoPrint.service
Wants=network-online.target

[Service]
Type=simple
User=pi
ExecStart=/usr/local/bin/webcamDaemon

[Install]
WantedBy=multi-user.target

I probably would have left everything where it was if I had not need to move to get the rc.local file to work. I did work that way, but I wanted to get the service to work so I commented out everything in rc.local and made the changes above and then reloaded the service. Works like I wanted it to now.

Thanks for that suggestion on how to specify the correct video device.

I added the ability to stop and start the webcam server through the Octorprint system menu but when I try the buttons I get this error for either button:

Error

The command "Stop video stream" could not be executed.

More

{"error":"Command for custom:streamoff failed: 500 Internal Server Error: Command for custom:streamoff failed with return code 1:\n\nSTDOUT:\n\n\nSTDERR:\nsudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper\n"}

Anybody have an idea what I did wrong?

When you run whatever command you configured through the terminal, it probably asks you for a password, which is not possible to do through OctoPrint running the command for you. You'll need to add an exemption for the command you want to run to the sudoers configuration, similar to how this guide shows it for the shutdown commands:

i see that the ExecStart thing is supposed to refer to /OctoPrint/venv/bin/octoprint but when I go to the .../venv/bin directory and do ls --all --classify I don't see any octoprint directory, so I did mkdir octoprint but I'm not sure what's supposed to go there lol

I would recommend you just use the octoprint_install script, as it will make things significantly easier across the board. GitHub - paukstelis/octoprint_install: Bash script for installing OctoPrint and webcam streamer

If anyone is looking for information about running OctoPrint with libcamera / Rasberry Pi Camera Module 3 as a webcam, I uploaded my setup instructions & scripts to GitHub

Just dropping a note of thanks for the devs and @foosel. I followed the guide and successfully set up OctoPrint on a 2012 Mac Mini running Ubuntu 22.04. Cheers!

The usb camera input file name does not always match /dev/video0 or /dev/video1. But it is possible to find out the device name using the v4l2-ctl utility, which can be installed with the apt install v4l2-ctl command. Once installed, you can query the list of video I/O devices using the v4l2-ctl --list-devices command. It will give you a list like this:

Video devices list (click me)
rockchip,rk3399-vpu-enc (platform: hantro-vpu):
        /dev/video3
        /dev/video4
        /dev/media1

rockchip-rga (platform:rga):
        /dev/video0

rkvdec (platform:rkvdec):
        /dev/video2
        /dev/media0

rockchip-iep (platform:rockchip-iep):
        /dev/video1

USB2.0 PC CAMERA: USB2.0 PC CAM (usb-xhci-hcd.0.auto-1):
        /dev/video6
        /dev/video7
        /dev/media2

In my case, in this list, I'm interested in a USB2.0 device that can be accessed through the file /dev/video6. I modified the webcamDaemon script a bit, adding to it requesting the webcam input file name:

# gets camera device name from v4l2-ctl output (search for USB devices in list and use first found)
camera_usb_device=$(v4l2-ctl --list-devices | grep "USB" -A 1 | tail -n 1 | sed -e 's/^[ \t]*//')
camera_usb_options="-r 640x480 -f 10 -d $camera_usb_device"

And also replace usb camera device existance check from: if [ -e "/dev/video0" ] to if [ -e "$camera_usb_device" ].
After reconnecting the USB camera, the file name changes and I just need to restart the webcamd service to restart streaming.

Hi. I have followed your guide and I'm not able to get the stream to function. I have moved the 2 files into their respective places after installing OctoPrint and did NOT use HAProxy. When I text my camera in a different OS it works fine and I can get a picture using libcamera-hello so I know it's not the camera. Any advice?
Using Pi4 4GB
Rasp Pi cam V3
Rasp Pi OS 32 bit lite (on PINN)
Thank you
Ruhel™

EDIT: I had to install picamera2 using

sudo apt install -y python3-picamera2

and it works perfectly.

Continuing the discussion from Setting up OctoPrint on a Raspberry Pi running Raspberry Pi OS (Debian):

There is no octopi.txt file if you install all of this manually, not sure what the equivalent would be. (running on a BTT cb1/pi4b if that's any help)

I have been through all the previous steps before this and everything works up until now.

Thank you for your very detailed and thorough explanation on how to install and run this app but I have no idea what you are saying. Can this app run on a chromebook and is it worth looking at if I have zero experience in programming and networking etc?

Ich kann leider kein gutes English und hoffe das man mir hier auch auf Deutsch helfen kann.

Meine Systemvoraussetzung ist ein Proxmox Server mit Debian 11 Bulseye, unter eine entsprechendem Debian VM.

Ich habe diese Anleitung schritt für schritt genaustens verfolg und eingegeben. Es hat auch soweit alles geklappt Octoprint läuft aber nur zum Teil als erstes der Drucker wird erkannt und kann ihn steuern die Webcam wir erkannt aber ich kann nur ein Snapshot machen und leider keinen Stream und ich kann Plugins weder über Respository noch über Download installieren. Es bricht mit folgendem Log ab.

*Installiere Plugin "Octolapse" von https://github.com/FormerLurker/Octolapse/archive/master.zip...
/home/pi/OctoPrint/venv/bin/python3 -m pip --disable-pip-version-check install file:///tmp/tmpjl37nyvw/Octolapse-master.zip --no-cache-dir
Processing /tmp/tmpjl37nyvw/Octolapse-master.zip
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'error'
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [20 lines of output]
likely tags: v0.4.2
picking v0.4.2
got version from expanded keyword {'version': 'v0.4.2', 'full-revisionid': 'c6c86782cdbfc3590fa4b1bf2e63064eb459b16b', 'dirty': False, 'error': None, 'date': '2023-04-02T10:23:21-0500'}
Traceback (most recent call last):
File "/home/pi/OctoPrint/venv/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in
main()
File "/home/pi/OctoPrint/venv/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(*hook_input['kwargs'])
File "/home/pi/OctoPrint/venv/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/pip-build-env-o49s97rt/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 338, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "/tmp/pip-build-env-o49s97rt/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-o49s97rt/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 484, in run_setup
super(_BuildMetaLegacyBackend,
File "/tmp/pip-build-env-o49s97rt/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 335, in run_setup
exec(code, locals())
File "", line 57, in
ModuleNotFoundError: No module named 'octoprint'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
Fehler!
Could not parse output from pip, see plugin_pluginmanager_console.log for generated output

In deinem octoprint python venv "pip install wheel" ausführen und dann nochmal versuchen.

Hat nicht geklappt, immer noch der selbe Fehler. Kann keine Plugins installieren.

Wie schaut's aus mit einen systeminfo bundle?

Nur nochmal zu Sicherheit, du hast schon das "oprint" pip für "pip install whee"l verwendet und nicht das vom OS, oder? Hatte letztens ein ziemlich ähnliches Problem. Konnte octoklipper über das entpackte Package und setup.py installieren, aber nicht über den package manager und auch nicht mit pip. siehe Setuptools error while installing plugin (octoklipper) on manual OP installation

Everything was going well until HAProxy. I'm totally lost now.
Perhaps I am trying to do something that is not possible.
I purchased a BTT Pad7 that includes a CB1 (Pi substitute). and a 7" touch screen. It's shipped with Klipper installed. I am underwhelmed by Klipper and figured I would try to use the hardware to run Octoprint so I could use it with my Marlin printer. It would be convenient to since the touchscreen and fake Pi are in a nice compact package.
Hopefully someone a lot smarter than me will figure it out and make a video.

This makes it as simple as possible: OctoPrint.org - Download & Setup OctoPrint

I have worked through this setup on a BTT Pi v1.2 without much trouble, but a couple of the command line bits puzzle me. I was thinking about doing some edits to help sort out the puzzles, but I thought I'd check to see if I've made the correct assumptions:

Under Optional: Webcam I found this:

I guessed that what was intended was this:

export LD_LIBRARY_PATH=`pwd`

If I'm in the ballpark, let me know, and I'll proceed with the edits. There are also a couple of other path items, and a clarification, but this is the tricky one.

By the way, it's working fantastically well. Great little board for Octoprint.

hi how do i uninstall octoprint . i want to reinstall using octoprint_deploy
thanks
martin

@paukstelis

1 Like