Filament manager postgresql error

I am trying to set up filament manager on OctoFarm and I am getting stuck connecting to the postgresql. Any assistance would be greatly appreacted. Thanks everyone.

octoprint (4).log (527.9 KB)

Please describe what steps you are following and where you get stuck in more details so someone can help. In the screenshot it has a link to a guide - are you following that? Exactly what problems are you having?

Thanks forthe response. I am following this guide.

Although I had to change the following line becasue I had a different version of postgresql

/etc/postgresql/9.6/main/postgresql.conf -> /etc/postgresql/11/main/postgresql.conf

everything appeared to insall fine. I am not sure where I went wrong.

Sorry, it was late last night when I was installing this and forgot that I was not able to get the ```
$ sudo apt install postgresql


https://community.octoprint.org/t/filament-manager-plugin-how-to-setup-postgresql-database/10698?page=2

When I run the following command I get an error " No such file or directory"
"~/oprint/bin/pip install --upgrade". I installed OctoPrint using the klipper app "kauah" so I believe I have to adapt the path so I tried navigating to the following dir. "~/OctoPrint.venv/bin" and I tried running "pip install --upgrade pip" and I get the "command not found" error. I noticedi have a pip3 option so I tried using the follwoing command "pip3 install --upgrade pip" which appear to be succsssful so I moved on

*pi@solo-octo-e3p:~/OctoPrint/venv/bin $ pip3 install --upgrade pip*
*Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple*
*Cache entry deserialization failed, entry ignored*
*Cache entry deserialization failed, entry ignored*
*Collecting pip*
*  Using cached https://files.pythonhosted.org/packages/1f/2c/d9626f045e7b49a6225c6b09257861f24da78f4e5f23af2ddbdf852c99b8/pip-22.2.2-py3-none-any.whl*
*Installing collected packages: pip*
*Successfully installed pip-22.2.2*

The next potential error I get comes at step "sudo apt-get install postgresql" Although it still appears to install successfully so I moved on.

Success. You can now start the database server using:

    pg_ctlcluster 11 main start

*Ver Cluster Port Status Owner    Data directory              Log file*

***11  main    5432 down   postgres /var/lib/postgresql/11/main /var/log/postgresql/postgresql-11-main.log***

*update-alternatives: using /usr/share/postgresql/11/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode*
*Setting up postgresql (11+200+deb10u5) ...*
*Processing triggers for systemd (241-7~deb10u8+rpi1) ...*
*Processing triggers for man-db (2.8.5-2) ...*
*Processing triggers for libc-bin (2.28-10+rpt2+rpi1+deb10u1) ...*

The next part that I get stuck at is the following. 

> *The Wiki says it best here, so you do this:*
> *Then append the following line to /var/lib/postgres/data/pg_hba.conf*
> 
> *host octoprint_filamentmanager octoprint 192.168.178.0/24 md5*

I do not have the directory "/var/lib/postgres"I do have a "/var/lib/postgreql" but no data photo. I do see a main folder but can not access it. Although I did add the host to the following file. "/etc/postgresql/11/main/pg_hba.conf"

After following the above tutorial and making the noted changes I now get the following error.

*

> Failed to connect to the database with the given configuration: No module named 'psycopg2'

*

It is worth noting that I did not get an error when running the following command which I modifed to run from my Octoprint dir.

~/oprint/bin/pip install psycopg2 -> cd OctoPrint, cd venv, cd bin, pip install psycopg2


Now what....

So I did some research and came across the following forum and tried the following. 

https://community.octoprint.org/t/filament-manager-plugin-how-to-setup-postgresql-database/10698


> *Steps 5 and 8 haven't been done while under the virtual environment of OctoPrint, btw.*
> 
> *If you wanted the working pip and python environment to be affected, you'd first need to do this before a pip-related command (and again if there was another reboot):*
> 
> **source ~/oprint/bin/activate**
> **But then again, does postgresql itself run from that virtual environment or not? If not, then your instructions would work for that. (But the virtual environment might also need to be updated for the sake of any plugins you write**

So I went back and ran the pip commands afer running the following command "source activate" from the `OctoPrint/venv/bin" dir

Still not success. Still getting the  "Failed to connect to the database with the given configuration: No module named 'psycopg2'"

I nexted tried the following from this forum. 
https://community.octoprint.org/t/filament-manager-external-database-cant-configure/1449/6

> *I did install psycopg2 as following:*
> 
> *Changed dir to: /Home/Pi/OctoPrint*
> 
> *virtualenv -p /usr/bin/python2 venv*
> 
> *sudo apt-get install libpq-dev this needs be installed, otherwise errors on psycopg2 installation.*
> 
> *~/OctoPrint/venv/bin/pip install psycopg2*

Same error... 

Once again, I appreciate any help.

Update...

I found a forum that mentioned doing the following.

And I get the following results.

> source activate
> (venv) pi@solo-octo-e3p:~/OctoPrint/venv/bin $ pip install psycopg2-binary
> DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at Release process - pip documentation v22.3.dev0 pip 21.0 will remove support for this functionality.
> Looking in indexes: Simple index, piwheels - Simple index
> Collecting psycopg2-binary
> Downloading psycopg2-binary-2.8.6.tar.gz (384 kB)
> |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 384 kB 2.8 MB/s
> Building wheels for collected packages: psycopg2-binary
> Building wheel for psycopg2-binary (setup.py) ... done
> Created wheel for psycopg2-binary: filename=psycopg2_binary-2.8.6-cp27-cp27mu-linux_armv7l.whl size=423087 sha256=ec057b1e1e7cdf6380d7c7a111226e2779f65f645dd903ae5895f8eb6935b1df
> Stored in directory: /home/pi/.cache/pip/wheels/fa/b9/c1/3db745f09e408d4e616feea0b91c430afa1b2183b96a36b22a
> Successfully built psycopg2-binary
> Installing collected packages: psycopg2-binary
> Successfully installed psycopg2-binary-2.8.6

Now when I test I get the error I was getting last night. Which is "FilamentManager is still initializing (if this persists, some dependencies may be missing)"

Update 2...

So I did the advice from this thread and adding the psycopg2_binary to the required dependency.

I had the same issue in my PrintJobHistory-Plugin. Try to patch the "setup.py" file.

** Download the Plugin as a Zip-File*
** Unzip*
** modifiy the setup.py. Add "psycopg2-binary" into the "plugin_requires" array (don't forget the comma)*
** zip*
** Install new zip via plugin manager*

Btw. which version of FM did you install?
There is already a patched version for OP 1.4, Pyhton 3: https://github.com/benjamin-salchow/OctoPrint-FilamentManager (but there is also the PostgresDriver missing)

and now I am making a little progress. It gets stuck with the message "Waiting for response"
This has been a journey. Hopefully someone can help me bring it home. Thanks in advance!

Did you upgrade your python to 3.x? The error shows you are using 2.7 which is no longer supported

I ended up starting over with a fresh image. I used the OctoKlipper image on the Raspberry Pi Imager. With the new image, I was ableto get postgresql working with no issues. I do miss moonsail a little but I had the need to cancel a part of a print with multiple parts and wasn't able to. I knew then that I need the plugins that OctoPrint offer so I switched back. But I'm keeping the Klipper FW...for now at least.

BTW:

https://www.klipper3d.org/Exclude_Object.html