Libraries Found when Running from the Command Line but Not When Running From Supervisor (Ubuntu 18.04)

You might want to do a quick sanity check to see if your supervisor is not just completely stopped or completely broken. Do this like so:

and you will see some output like:

See how the bottom line says exited? Check that out. That can happen if you have something screwy in your supervisor.conf file.

You can find your supervisor config file under /etc/supervisor if you installed with apt-get. You can check that file to see where your logs are. You probably want to install this way as opposed to pip so that supervisor will start on system boot.

My logs are under /var/log/supervisor.

Running from the command line I can run my script just fine but when I check the supervisor logs I see:

In your supervisor.conf file where you have your program defined, there is a property called environment. I can usually add my PATH to that environment and get most things working just by doing that. There is usually a few stragglers though that I have to find the path to and add in manually.

I pretty much do

and then paste the result of that in the supervisord.conf file. (You have to add in PATH= part yourself too)

so where is the path to cv2?

Do this. Open a console session by typing python3 and pressing enter.

You’ll see that your prompts now start with >>>.

Type in these two lines to see the path to the cv2 module. Replace cv2 with whatever module it is that you in particular are looking for.

I got the result:

Take the .so file (or whatever file in your case) off the end and add that to the path in your supervisor environment variable. ie. just this part:

Add this:

You’re basically adding the path to cv2 to an environment variable for supervisor called PYTHONPATH. (scroll horizontally to the end if you can’t see it)

Do these two commands to restart your supervisor. If you are in charge of a bunch of important stuff, you might want to make sure that your long running processes are not in the middle of doing something first.

Now when I do this:

I can see that I have fixed the opencv error because it has moved on to the next module it can’t find. Repeat this for every module that supervisor can’t find and you should be good.

Research and Development | Dev Ops | Software Engineer | Topaz Labs

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store