Setting up OctoPrint on Ubuntu 20.04 with Python 3

Post by:

Alex

Published:

June 5, 2020

Categories:

Note: This post was originally on my personal blog. I have moved it here as it relates to what we do.

Overview

I had been running OctoPrint on a small embedded PC that I had, but it was not running as well as I would have liked. This original build was kinda slapped together and not quite as streamlined as I had intended it to be. It worked, mostly, but wasn’t running OctoPrint as a service, and required a manual start of the webcam software on reboot, so just kinda meh.

I decided to kick it up a notch with a more powerful embedded PC that I had laying around, with more disk space, RAM and processing power. Not that the other unit was under-powered (I mean you can run this on a Pi), but I had the hardware, so why not?! Here is how it all went together, for posterity, and for anyone else looking to do this. I will list the sources that I followed at the end of the post.

This guide assumes that you have some familiarity with working in command line LINUX. If you don’t, google may be your friend. Additionally, anywhere you see me use either my username “alex” or “[USER]” you should replace that with your user name.

Install the OS

First off, I started with a fresh download of Ubuntu Server 20.04 LTS. You can download that right from the Ubuntu Site. I use Balena Etcher to write out my live USB stick, it is available for both Mac and Windows. Of course you can use your favorite image writing tool as well.

This install and initial setup is down with a local keyboard and display. once you are set up with the OS, you can switch to your favorite SSH client.

I set the BIOS on my embedded PC to defaults, and the OS type to LINUX. This step will vary depending on the hardware that you install on.

Once booted to the live USB, I did a pretty vanilla install of Ubuntu server. It is worth noting that I needed to have a network connection for the install, or my networking didn’t seem to work right after, so you may need to make sure you have an active network connection. I just did a basic install without any extra software, and with OpenSSH installed. Set your user name, computer name, short name, and password, and let it do it’s thing.

After the OS installation was complete, a reboot brings you into the command prompt. As with any new install, I recommend doing a quick update check and install any updates (this code will update your package list and install any available upgrades):

sudo apt update && sudo apt upgrade -y

I also recommend installing net-tools so that you can use commands like ifconfig to get your IP address:

sudo apt install net-tools

At this point, it is a pretty good idea to reboot your computer. I mean, you just did updates and install new software, so it can’t hurt.

sudo reboot

At this point, you can switch to connecting to your machine via SSH from your favorite SSH client. On a mac, you can just use Terminal. On windows, use a program like PuTTy. Of course, you can also continue to work locally on the machine as well. I just like working in an SSH client because I can keep the client side-by-side with the guide, and I can copy and paste all the commands rather than typing them out!

Installing OctoPrint

Once your computer reboots, it is time to start getting ready for the actual OctoPrint install. While Ubuntu 20.04 does come with Python 3, you still need a few other bits for everything to work right. You could do this before the reboot above if you wanted. You can install the needed components with the following command:

sudo apt-get install python3-pip python3-dev python3-setuptools python3-virtualenv git libyaml-dev build-essential

Now we have to set up the Python virtual environment in the correct directories. For now you should be in your user home directory “/home/[USER]” or the “~” directory. If you are not then just:

cd ~

You can check the absolute path to the current directory with:

pwd

So, we need to make the OctoPrint directory and get into it:

mkdir OctoPrint && cd OctoPrint

Next we are going to setup the virtual environment running Python 3:

virtualenv --python=python3 venv

Now we are going to activate the virtual environment:

source venv/bin/activate

Once you do this step, your command line should be preceded by “(venv)” This indicates that you are working in the virtual environment, which is what we want.

Then we are going to install the latest version of PIP:

pip install pip --upgrade

Next we are going to use PIP to install OctoPrint. This will download the necessary files from the OctoPrint repository and set it up in the virtual environment.

pip install https://get.octoprint.org/latest

Once the install is completed, we need to make sure that your user is a member of the tty and dialout groups in the system. This makes sure that OctoPrint can use serial connections to talk to your printer! Remember to use your user name, not mine!

sudo usermod -a -G tty alex
sudo usermod -a -G dialout alex

Now you should have OctoPrint installed and ready to use. You can test it by issuing the following command:

~/OctoPrint/venv/bin/octoprint serve

When you use the above command, you will see the server start to run. If you open a web browser and point it at the IP address of your OctoPrint device and port 5000, you should see the OctoPrint Setup screen! For me, for this device i used: http://192.168.0.153:5000. Your IP address will depend on your network settings.

You can go through the setup now, if you would like, but I did it later. Back in your terminal, lets stop the server. This can be done by pressing control-c. This will terminate the server process and return you to a command line.

Automating OctoPrint Startup

Now that we have OctoPrint installed and working, it is time to set it up so that it will start automatically when the computer boots up. Fortunately, there are sample scripts available from the OctoPrint GitHub. All we have to do is download them and update them to match our install. We are going to download the scripts and move them to the correct locations. We also need to make sure that they are executable.

wget https://github.com/foosel/OctoPrint/raw/master/scripts/octoprint.init && sudo mv octoprint.init /etc/init.d/octoprint

wget https://github.com/foosel/OctoPrint/raw/master/scripts/octoprint.default && sudo mv octoprint.default /etc/default/octoprint

sudo chmod +x /etc/init.d/octoprint

You can check that your script is executable by listing the contents of /etc/init.d. If the script shows up in green, it is executable.

ls /etc/init.d

Now we need to tweak the scripts to match our installation. This means that we need to uncomment a couple lines in the script and make sure that the user name and file paths are correct. See the example below, just replace my username with yours. Edit the script using nano.

sudo nano /etc/default/octoprint

Your script should look something like this:

# Configuration for /etc/init.d/octoprint

# The init.d script will only run if this variable non-empty.
OCTOPRINT_USER=alex

# base directory to use
BASEDIR=/home/alex/.octoprint

# configuration file to use
CONFIGFILE=/home/alex/.octoprint/config.yaml

# On what port to run daemon, default is 5000
PORT=5000

# Path to the OctoPrint executable, you need to set this to match your installation!
DAEMON=/home/alex/OctoPrint/venv/bin/octoprint

# What arguments to pass to octoprint, usually no need to touch this
DAEMON_ARGS="--port=$PORT"

# Umask of files octoprint generates, Change this to 000 if running octoprint as its own, separate user
UMASK=022

# Process priority, 0 here will result in a priority 20 process.
# -2 ensures Octoprint has a slight priority over user processes.
NICELEVEL=-2

# Should we run at startup?
START=yes

Now we have to add our scripts to autostart. This is done with the following command:

sudo update-rc.d octoprint defaults

Now you should be able to run OctoPrint as a service using the following command:

sudo service octoprint start

You can check if OctoPrint is running by using this command (or visiting the site in a browser):

sudo service octoprint status

We have one last thing to do in order to give the OctoPrint UI the ability to shutown or reboot the computer as well as the ability to restart the OctoPrint service. We will give our user the ability to run a couple sudo commands without requiring a password. We are going to create a simple file in sudoers.d that grants permissions. This is a little safer than directly editing your sudoers file. You can do this with nano, but it will not check your syntax like vi does. I personally like nano better, but make sure your get the syntax right or you might end up locking yourself out of being able to run sudo commands completely. (it is possible to recover from that if you do it…)

First, let’s open a new document in your favorite editor:

sudo nano /etc/sudoers.d/octoprint-shutdown

Then in that document we will put the following:

alex ALL=NOPASSWD: /sbin/shutdown
alex ALL=NOPASSWD: /bin/systemctl restart octoprint.service

Save and close when you are done. As always, make sure that you use your user name or this will not do much for you.

Run OctoPrint on port 80

Now that we have OctoPrint up and running and starting on boot, assuming that OctoPrint is the only web service that you are running, we can make it default to port 80 (the standard http port) so that you don’t have to enter the port number in the URL when you want to access it. We do this with haproxy.

First we need to install haproxy:

sudo apt install haproxy

Next we will make a backup copy of the haproxy config file and delete the original. We are just going to replace it with our own later:

sudo cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg_old
sudo rm /etc/haproxy/haproxy.cfg

Next, open up an editor to make a new config file:

sudo nano /etc/haproxy/haproxy.cfg

Paste the following into the haproxy.cfg file:

global
        maxconn 4096
        user haproxy
        group haproxy
        daemon
        log 127.0.0.1 local0 debug

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        option http-server-close
        option forwardfor
        maxconn 2000
        timeout connect 5s
        timeout client  15min
        timeout server  15min

frontend public
        bind :::80 v4v6
        use_backend webcam if { path_beg /webcam/ }
        default_backend octoprint

backend octoprint
        reqrep ^([^\ :]*)\ /(.*)     \1\ /\2
        option forwardfor
        server octoprint1 127.0.0.1:5000

backend webcam
        reqrep ^([^\ :]*)\ /webcam/(.*)     \1\ /\2
        server webcam1  127.0.0.1:8080

Next we will enable haproxy. We are just adding “ENABLE=1” to the last line of the file. So open the file:

sudo nano /etc/default/haproxy

Then make sure that your file looks like this:

# Defaults file for HAProxy
#
# This is sourced by both, the initscript and the systemd unit file, so do not
# treat it as a shell script fragment.

# Change the config file location if needed
#CONFIG="/etc/haproxy/haproxy.cfg"

# Add extra flags here, see haproxy(1) for a few options
#EXTRAOPTS="-de -m 16"
ENABLE=1

You then should restart haproxy to make sure that all changes take effect:

sudo service haproxy restart

Of course you can check if haproxy is running using the command below, or you can just try to visit the URL of your server without the port number on the end.

sudo service haproxy status

Setup the WebCam Software

Now we all know that making timelapses of 3D prints is awesome, and one of the great features of OctoPrint is its webcam integration. Let’s get that working now too.

First off, change back to your home directory and then we need to install a handful of software:

cd ~
sudo apt install subversion libjpeg8-dev imagemagick ffmpeg libv4l-dev cmake

When you install those packages, there will be a lot of other dependancies that get installed with them. You do want it all.

Next we will grab mjpg-streamer from github and move into its directory:

git clone https://github.com/jacksonliam/mjpg-streamer.git
cd mjpg-streamer/mjpg-streamer-experimental

Now we have to export the library and make the software (these steps may take some time):

export LD_LIBRARY_PATH=.
make

Once the make is complete, we can test the software:

sudo ./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so"

Of course we want the webcam software to start automatically as well, so we need to make a couple more scripts to do this. We are going to make a scripts folder in your home folder and then create a script to start and stop MJPEG-Streamer called “webcam.” As always, make sure to change the user name to match yours! DO NOT USE sudo when executing these commands.

cd ~
mkdir scripts
nano /home/alex/scripts/webcam

Here is the start/stop script, go ahead and paste this script into the editor, remember to change user names!

#!/bin/bash
# Start / stop streamer daemon

case "$1" in
    start)
        /home/alex/scripts/webcamDaemon >/dev/null 2>&1 &
        echo "$0: started"
        ;;
    stop)
        pkill -x webcamDaemon
        pkill -x mjpg_streamer
        echo "$0: stopped"
        ;;
    *)
        echo "Usage: $0 {start|stop}" >&2
        ;;
esac

Now create a second script “webcamDaemon” (note again, not using sudo):

nano /home/alex/scripts/webcamDaemon

And paste the following into the editor, updating for your user. You can also change the default video resolution and framerate in this script:

#!/bin/bash

MJPGSTREAMER_HOME=/home/alex/mjpg-streamer/mjpg-streamer-experimental
MJPGSTREAMER_INPUT_USB="input_uvc.so"
MJPGSTREAMER_INPUT_RASPICAM="input_raspicam.so"

# init configuration
camera="auto"
camera_usb_options="-r 640x480 -f 10"
camera_raspi_options="-fps 10"

if [ -e "/boot/octopi.txt" ]; then
    source "/boot/octopi.txt"
fi

# 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=. ./mjpg_streamer -o "output_http.so -w ./www" -i "$input"
    popd
}

# starts up the RasPiCam
function startRaspi {
    logger "Starting Raspberry Pi camera"
    runMjpgStreamer "$MJPGSTREAMER_INPUT_RASPICAM $camera_raspi_options"
}

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

# we need this to prevent the later calls to vcgencmd from blocking
# I have no idea why, but that's how it is...
vcgencmd version

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

# keep mjpg streamer running if some camera is attached
while true; do
    if [ -e "/dev/video0" ] && { [ "$camera" = "auto" ] || [ "$camera" = "usb" ] ; }; then
        startUsb
    elif [ "`vcgencmd get_camera`" = "supported=1 detected=1" ] && { [ "$camera" = "auto" ] || [ "$camera" = "raspi" ] ; }; then
        startRaspi
    fi

    sleep 120
done

We now have to make these scripts executable, so run the following commands (update for your user):

sudo chmod +x /home/alex/scripts/webcam
sudo chmod +x /home/alex/scripts/webcamDaemon

To get the webcam to start on reboot, we are going to make an rc.local file. This will just execute the camera startup script. Create the file using nano:

sudo nano /etc/rc.local

Then paste this simple script into it (change user names):

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/home/alex/scripts/webcam start

exit 0

Now we need to make rc.local executable:

sudo chmod +x /etc/rc.local

Finally, we can start the webcam (change user names):

sudo /home/alex/scripts/webcam start

Use a URL not IP address

If you want a clean way to access your OctoPrint server so that you don’t have to remember the IP address of it, we can do that with Avahi (aka Bonjour). First, we need to install Avahi:

sudo apt install avahi-daemon

Then we are going to create a file with the hostname that we would like to use:

sudo nano /etc/hostname

In the editor, just type the hostname you want on the first line. then save and exit. Mine is “icewolf3d”

Then we need to edit the hosts file to use that host name. Open the hosts file in nano:

sudo nano /etc/hosts

You need to either include the hostname on the line for 127.0.1.1 or add a line. My hosts file looks like this:

127.0.0.1 localhost
127.0.1.1 icewolf-3dsrv icewolf3d

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Of course, save and close the file when you are done.

Lastly, it is time to reboot the system:

sudo reboot now

Configuring OctoPrint

I am not going to go into too much detail on how to set up OctoPrint as it is pretty straight forward, and a little different depending on your printer. However, there are a couple things that are useful. Once you go through the initial setup you may need to fill in the following information:

Shutdown commands (I don’t actually use the shutdown command as my system is not designed for that):

Restart OctoPrint: sudo /bin/systemctl restart octoprint.service
Restart System: sudo shutdown -r now
Shutdown System: sudo shutdown -h now

Webcam links:

Stream URL: /webcam/?action=stream
Snapshot URL: http://127.0.0.1:8080/?action=snapshot
Path to FFMPEG: /usr/bin/ffmpeg

Onward Ever Upward…

…oh faithful followers of Waldo!

At this point you should have a functional install of OctoPrint that starts on boot and is web-cam ready. Since this runs in Python 3, not all plugins are compatible yet, but many are. I definitely recommend the OctoPod plugin along with the iOS app (I think there is an Android one as well). It gives you all the great functionality of OctoPrint in an app along with notifications.

My next plans for this system are to get it connected to my NAS for storage of timelapse videos as well as my gcode repository. The HDD of the server is plenty big for it all, but it seems like it would be convenient if I got it all in one place and easily accessible anywhere on my network.

My printer setup now

Ender-3 with Micro-Swiss Direct Drive and all-metal hotend, satsana fanduct with 5015 blower, spring steel PEI plate, Wyze cam converted to webcam, and my OctoPrint server on the shelf below.

Resources

I used the following sources to aid in this journey. Credit where credit is due:

41 Comments

  1. Frenchy

    Great guide! However, I don’t think that you need to install subversion 🙂

    Reply
    • Alex

      I believe you are correct. It may be a holdover from earlier testing that I was doing, and just held on to the commands.

      Reply
  2. Tod Wulff

    Good day.

    The guide seems to be missing the step/command to open the hosts file: sudo nano /etc/hosts

    Otherwise, you’ve crafted a wicked good guide. Thank you, kind sir!

    -MHz

    Reply
    • Alex

      MHz- You are absolutely correct, I totally missed the command for editing the hosts file. I shall add that in! Thanks!

      Reply
  3. Kail

    I went through the steps. However, when I used “~/OctoPrint/venv/bin/octoprint serve” it said “No such file or directory”

    Reply
  4. Kail

    Disregard that message and forgive my ignorance haha. I’m brand new to linux, but I figured it out! 🙂 Thanks so much for this guide!!

    Reply
    • Solomon

      i got stuck on this as well what did you do? i am also new to linux it is giving me the same error

      Reply
  5. Ryan

    Thank you for making this awesome guide! I followed it completely, but do not know how to access my server from the hostname I set up. For your example, icewolf3d was the hostname, so what do you put in your web browser to connect using this hostname? Thanks again!

    Reply
    • Alex

      You should be able to use *.local as the URL. So, in my case it is “icewolf3d.local”

      Reply
  6. Angelo

    Almost there…

    here I got stuck at:

    sudo service haproxy restart

    Job for haproxy.service failed because the control process exited with error code.
    See “systemctl status haproxy.service” and “journalctl -xe” for details.

    Reply
    • AMG

      you need to replace ‘reqrep’ with ‘http-request replace path’ in the .cfg file

      Reply
      • Andy

        I actually found I needed more changes to get it working with HaProxy 2.1+:

        “`
        backend octoprint
        http-request replace-path ^([^\ :]*)\ /(.*) \1\ /\2
        option forwardfor
        server octoprint1 127.0.0.1:5000

        backend webcam
        http-request replace-path /webcam/(.*) /\1
        server webcam1 127.0.0.1:8080
        “`

        Reply
  7. evi

    Hi! Great guide!! You are a GOD! Thank you sooo much. I need to add something because I had only one issue and I found out how to solve it, so it might help others.

    For me Stream URL: /webcam/?action=stream didn’t work. Screenshot was working fine though. In octoprint settings under Webcam and timelapse there is a note. Note: Please note that OctoPrint merely embeds a webcam stream & access a snapshot URL. It does not actually run its own webcam server or interact directly with your camera. It thus can’t impose access restrictions on it or enable/disable the stream for you. Please see this FAQ entry for more explanation.

    So in order for the webcam to stream successfully you have to access Octoprint from another computer and test it (or your mobile phone). So, used this stream URL and I got it working http://192.168.1.38:8080/?action=stream (replace 192.168.1.38 with your linux server IP)

    Reply
    • wiiizbe

      hi, thank you for your sharing, i had the same problem and your comment help to solve it.
      Thank you for taking the time to share

      Reply
    • Chris Klinger-Backen

      Thank you so much!!

      Reply
  8. Erik Middeldorp

    I was having problems with octoprint not being able to restart itself after updates and the “Restart Octoprint” controls not working. I fixed it by changing /etc/sudoers.d/octoprint-shutdown from
    erik ALL=NOPASSWD: /bin/systemctl restart octoprint.service
    to
    erik ALL=NOPASSWD: /usr/sbin/service
    I guess I might’ve also been able to fix it by changing the Restart Octoprint command in the Octoprint Settings.

    Reply
  9. graffx

    Thank you for convenient guide!
    Can’t get the stream to work in Octoprint –
    It’s working on 192.168.x.x/webcam/?action=stream (without the port :5000) – but not in Octoprint and not on 192.168.x.x:5000/webcam/?action=stream
    Double checked all the scripts and configs.. I’m noob at linux, can you help me please?

    Reply
  10. Drew

    Hey so I’m a relative noob to Linux here but I’ve followed this guide and managed to get everything up and running, so kudos for the great guide. The only thing I’m missing out on is the ability to restart octoprint from within the web client, I get the success message, and I can see in the terminal on the webpage that it attempted to send the “sudo bin/systemctl restart octoprint.service” but octoprint doesn’t actually restart. Any advice would be helpful, as I really have no idea what has happened here.

    Reply
  11. wiiizbe

    just incredibly clear !
    you hepled me a lot !

    Thank you for your work and for your sharing 🙂
    Hopefully people like you continue to exist

    Reply
  12. Dan Pro

    I was doing fine until editing scripts using nano. I clicked where I wanted to edit with my mouse and started backspacing. I’ve not worked in this environment before. I now know that arrow keys move me around. I replaced what I thought was removed (part of my username) and continued. In the end sudo update-rc.d octoprint default, sudo service octoprint start and sudo service octoprint status commands didn’t appear to do anything and I can’t open octoprint in my browser. How would I delete the octoprint directory so I could take another run at it?

    Reply
    • Alex

      All the text editors in the command line won’t be happy about trying to use your mouse. It takes a little getting used to, but at least Nano is a bit more intuitive than VI. That said, there are a bunch of people who like VI…

      As far as getting rid of your OctoPrint directory, you can use the following command: rm -r ~/OctoPrint/ This will remove the directory you crated everything inside of and all subdirectories.

      Reply
      • Dan Pro

        Thanks for the command it did the trick.
        After editing you should mention Ctrl X ,Y and enter to save.
        I figured that out reviewing Chris’s Basement video to see what else I was doing wrong.
        I have never used linux before and have no idea what I’m doing.
        Do you mind helping me next time I get stuck?

        Reply
        • Logan

          Hi, was wondering if you could help me. The server and everything is good but it can’t seem to connect to my printer. I’ve tried different cables and USB ports on my server. The error code 13 keeps coming up in the octoprint terminal.

          Changing monitoring state from “Offline” to “Error: Connection error, see Terminal tab”
          Unexpected error while connecting to serial port: /dev/ttyUSB0 SerialException: ‘[Errno 13] could not open port /dev/ttyUSB0: [Errno 13] Permission denied: ‘/dev/ttyUSB0” @ comm.py:_openSerial:2691 (hook default)

          Reply
  13. MMarty64

    Just wanted to say thanks for the great walkthrough. I used it to install on Octoprint on Proxmox VM with USB passed through. Worked Perfectly.

    Did I say the walkthrough was excellent? I’m a Linux Hack and this was just what I needed.

    Cheers!

    Reply
    • Alex

      Glad you found it helpful!

      Reply
  14. Yohan51

    Hi,
    Good job guy, it was really helpfull for me.
    As Evi said, “For me Stream URL: /webcam/?action=stream didn’t work” but I solved it by using “http://192.168.1.***:8080/?action=stream” instead. But the stream is from my laptop cam and I wan’t to use an action cam plugged with USB. How can I manage it please ?
    Does anyone has an idea ?
    Thanks

    Reply
    • Alex

      There is a way to specify which camera to use, I don’t remember it offhand. I will try to look it up. It is just a matter of getting the device ID and putting it in the config for the streaming software.

      Reply
      • Brandon

        Did you ever find out what the changes are to be made for this? I’m running into this too where it is trying to use the horrible webcam built into a laptop as opposed to my good hd usb camera I have attached.

        Reply
  15. adam

    legit followed this too the T…. get to the

    “Of course you can check if haproxy is running using the command below, or you can just try to visit the URL of your server without the port number on the end.

    sudo service haproxy status”

    services are running but no matter how hard i try i cant access the octoprint UI…… im going crazy please help bout to go back to windows!!!

    Reply
    • Alex

      If I understand you correctly, you are saying that from another computer on your network you cannot get to the OctoPrint UI? Have you tried using the IP address of the octoprint server instead of the URL? If you can access the UI using the IP address, it would indicate an issue with HAProxy. If you cannot access the UI using the IP address, then it may indicate that either octoprint is not running, or is not quite configured correctly.

      Reply
  16. Andrew

    Excellent guide…used it to repurpose an old Surface Pro (1st-gen) to be a beefier OctoPrint server (was running OctoPi on a Pi 3, with a TFT screen, and it was great for remote use, but pretty terrible for local control).

    Haven’t set up camera yet, but it’ll be interesting to see how that works given the built-in front/back cameras in the surface (I’ve also got a logitech C270 that’s been my main camera on this printer.

    One tip from my experience…if you’ve used the Snap install of OctoPrint (don’t, but I did), it may hold onto port 5000 even if you uninstalled it. My simple workaround was to use port 5001 in the config file.

    Reply
  17. David Green

    Where do i get the vcgencmd utility? I can’t find it in the Ubuntu repos and it appears to be part of the Raspberry Pi packages.

    Reply
    • BiOs2k

      apt install python3-cffi

      Reply
  18. Craig

    My octoprint starts using the command “~/OctoPrint/venv/bin/octoprint serve” but it doesn’t start using the command “sudo service octoprint start”. Checking the status is says, “Not starting octoprint, DAEMON not set in /etc/default/octoprint.”

    My script is setup exactly like the example except using my username of course. Any idea what could be wrong?

    Reply
  19. Alex Israels

    Hi Alex,

    First and foremost, great guide. I had gone through it earlier this year and had no issues with the setup. I’ve had to move my printer into the basement and couldn’t get my computer to boot, so had to do a fresh install of ubuntu and started trying again.

    I couldn’t find your guide at first and went through and followed a different one: https://all3dp.com/2/octoprint-linux-ubuntu-tutorial/ (my mistake). I ran into issues related to the user setup (using userAdd set the default shell to sh not bash so python commands like `source` weren’t working).

    Anyways, I tried removing that user and all their files with `userDel` and `rm -r OctoPrint` and started this tutorial over after creating the user with addUser (sets default shell to bash). Everything seemed to be going fine until I tried to start the octoprint service with `sudo service octoprint start`. Now I get the following error:

    Failed to start octoprint.service: Unit octoprint.service has a bad unit file setting.
    See system logs and ‘systemctl status octoprint.service’ for details.

    I’m not really familiar with unit files and how to adjust them. I would really appreciate any help to resolve this. I’m assuming that there is some conflict or improper overwriting of the service from the initial setup.

    Reply
  20. Todd

    for the life of me I cannot get FFMPEG to be found

    /usr/bin/ffmpeg

    The path doesn’t exist, yes it is installed…

    octopi:~$ which ffmpeg
    /usr/bin/ffmpeg

    Reply
  21. Craig

    I’m new to 3D printing and was starting to hate having to keep using the sdcard etc and friends recommended I use Octoprint so thought I’d give it a go. I decided to install in on my 2010 MacMini running ZorinOS 16 Pro as it wasnt really using due to its low spec and got to say that this guide is great work and I had everything up and running in next to no time. Big thank you to Alex for writing such a thorough and easy to follow guide. I’m forever thankful and now happily printing using OctoPrint. Thank you

    Reply
    • Alex

      Glad it was helpful and that you are up and running. Happy printing!

      Reply
  22. Kyle

    I had an issue with this command “sudo apt install subversion libjpeg8-dev imagemagick ffmpeg libv4l-dev cmake” turns out, the repository I was using wasn’t letting it download or something. Had to change the repository temporarily in “/etc/apt/sources.list.”

    If you are using Uncomplicated Firewall, make sure to let ports 80 (webpage), 8080 (webcam), possibly 5000 if nothing else is showing OctoPrint when you go to your browser with “server-address”. “server-address:5000” should then work.

    Reply
  23. Kyle

    **Solution** Camera won’t work if unplugged and plugged back in.

    For anyone who wants Octoprint to reconnect the webcam if it gets unplugged and reconnected, I spent like 4 hours but found a reliable fix… I think… I’m new to linux/ubuntu and ChatGPT helped me with it.

    here is a link to the paste bin to what I copied and pasted into the “webcamDaemon” file.
    https://pastebin.com/edz5kkxJ

    TBH, I have no idea what it does other than kill and restart the camera and the mjpg_streamer when a camera gets disconnected and reconnected. (I don’t know if it works when changing out the model of webcam or not)

    Reply

Leave a Reply to Kail Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Location

We are located in Mt. Gretna, PA. If you are doing local pickup, we will send you an address.