tjfontaine / airprint-generate

Automatically generate AirPrint Avahi service files for CUPS printers
http://www.atxconsulting.com/blog/tjfontaine/2010/11/21/automatically-generate-airprint-avahi-service-files-cups-printers
400 stars 119 forks source link

No module named 'urlparse' and No module named 'StringIO' #20

Closed TheRoarkster closed 3 years ago

TheRoarkster commented 4 years ago

This is an old, un-updated script that lots of people still use but has not kept up with python changes. If you get either of the above errors you need to just:

cd /opt/airprint
sudo nano airprint-generate.py

[Edit]

#import cups, os, optparse, re, urlparse
import cups, os, optparse, re, urllib.parse

[Edit]

#from StringIO import StringIO
from io import StringIO

I would just try to branch, but I am not a skilled programmer and just found these edits through searches.

branx86 commented 4 years ago

I have CentOs 8 and did the Edit import cups, os, optparse, re, urllib.parse , from io import StringIO Now I have : File "./airprint-generate.py", line 277, in apg.generate() File "./airprint-generate.py", line 127, in generate uri = urlparse.urlparse(v['printer-uri-supported']) NameError: name 'urlparse' is not defined

branx86 commented 4 years ago

Is their missing depend or do I have the wrong Python version Using (/usr/bin/Python3)

branx86 commented 4 years ago

Well figured out the above problem by Doing in CentOs 8 " pip2 install cups" and " pip3 install cups" now I have : File "./airprint-generate.py", line 261, in cups.setPasswordCB(getpass) AttributeError: module 'cups' has no attribute 'setPasswordCB'

tjfontaine commented 3 years ago

much of this has been fixed in 0384693e462ee6a0bf9237a839d73d4c6a720cd3 though I would suggest using the docker container that you can build from the repo.