'Why I can't create a cups connection in my raspberry pi using python?
I want to use python code to print to my printer. I installed all the required module but it's not running. The error I got is
Traceback (most recent call last):
File "/home/pi/Thesis/print_usingcups.py", line 2, in <module>
conn = cups.Connection()
AttributeError: module 'cups' has no attribute 'Connection'
I got the code from the internet here's the code
import cups
conn = cups.Connection()
printers = conn.getPrinters ()
for printer in printers:
print (printer, printers[printer]["device-uri"])
my expected output is like this
EPSON_LX-300 usb://EPSON/LX-300+?serial=L010209081
RICOH_Aficio_SP_100 usb://RICOH/
Aficio?serial=T382M977983 but I received an error.
Solution 1:[1]
Attempting to run pip install pycups results in the error below:
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-g7Dc7A/pycups/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-4JsSZe/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-install-g7Dc7A/pycups/
Running pip3 install pycups IS successful; however I continue to get "no module named cups". I will continue to investigate and post a solution if I find one.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mike |
