I'm using Virtualenvwrapper which I installed with;
sudo pip3 install virtualenvwrapper=='4.8.4'
and put the following at the bottom of both /home/pi/.bashrc and .profile;
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.7
export VIRTUALENVWRAPPER_VIRTUALENV=/user/local/bin/virtualenv
export VIRTUALENVWRAPPER_ENV_BIN_DIR=bin
export PATH=/usr/local/bin:$PATH
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh #and yes that's been confirmed by a directory walk as the correct place
Then once that was done I used;
mkvirtualenv venv3
which automatically puts you in the virtual environment
I then ran
pip3 install pip --upgrade
pip3 install --no-cache-dir octoprint
Then left the virtual environment with
deactivate
/etc/systemd/system/octoprint_py3 contains;
[Unit]
Description=The snappy web interface for your 3D printer
After=network-online.target
Wants=network-online.target
[Service]
Environment="LC_ALL=C.UTF-8"
Environment="LANG=C.UTF-8"
TYPE=simple
User=octoprint
ExecStart=/home/pi/.virtualenvs/venv3/bin/octoprint
[Install]
WantedBy=multi-user.target
I set up the users with;
sudo useradd --groups dialout,tty --create-home --system --shell /bin/bash octoprint
sudo useradd --groups video --create-home --system --shell /bin/bash webcam
Then used the command
sudo visudo -f /etc/sudoers.d/020_octoprint
with the following contents
Cmnd_Alias SHUTDOWN_CMDS = /sbin/poweroff, /sbin/reboot
Cmnd_Alias SUPERVISOR_COMMANDS = /usr/bin/supervisorctl
octoprint ALL=(ALL) NOPASSWD: SHUTDOWN_CMDS, SUPERVISOR_COMMANDS
Then used;
sudo visudo -c
to make sure that worked.
I made sure to use after making the edits on the files below (init.d and default files);
sudo chmod +x /etc/init.d/octoprint_py3
sudo systemctl daemon-reload
sudo update-rc.d octoprint_py3 defaults
sudo service octoprint_py3 start
But it completely ignores the fact that the init.d file tells it to use port 5001 instead of the default.
I've made sure to edit /etc/init.d/octoprint_py3 so that the file contains;
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="OctoPrint_py3 Daemon"
NAME="OctoPrint_py3"
DAEMON=/usr/bin/octoprint
PKGNAME=octoprint_py3
PIDFILE=/var/run/$PKGNAME.pid
SCRIPTNAME=/etc/init.d/$PKGNAME
DEFAULTS=/etc/default/$PKGNAME
and I've edited /etc/default/octoprint_py3 to;
OCTOPRINT_USER=octoprint
BASEDIR=/home/pi/.virtualenvs/venv3
CONFIGFILE=/home/pi/.virtualenvs/venv3/config.yaml
PORT=5001
DAEMON=/home/pi/.virtualenvs/venv3/bin/octoprint
DAEMON_ARGS="--host=$HOST --port=$PORT --config=$CONFIG --basedir=$BASEDIR"
UMASK=000
NICELEVEL=-2
START=yes
If I type
sudo service octoprint_py3 start
the web interface start up on port 5000 which from all I can tell it shouldn't.... it should be on port 5001 if it's using the files above.... so I'm stumped.
There's no errors I can find, nothing throwing a fit or showing where it's wrong.... it just skips the files.
sudo servive octoprint_py3 stop
stops the service just fine and restart and status also work and show nothing that looks odd. Restarted the Pi just on the off chance but that didn't change anything.
Virtualenvwrapper is 4.8.4 . Can't seem to get 5 working. OctoPrint is version 1.4.2, I'm using a Raspberry Pi 4 8GB with Raspbian 32bit on a 128GB microSD
Apologies if I missed anything. Been trying to get this working correctly for a few days and I may have forgotten a step or 2.