0

I try to convert python2 to python3 and there is code not working on `cups.Connection()``

import cups
conn = cups.Connection()

And its produce stacktree

Traceback (most recent call last):
  File "/Users/sagara/Downloads/Printing Script/mnd_75 (latest).py", line 177, in <module>
    conn = cups.Connection()
           ^^^^^^^^^^^^^^^
AttributeError: module 'cups' has no attribute 'Connection'

I already uninstall pycups from This and install it again The python version its Python 3.11.2 with pyenv and the pycups version its

Requirement already satisfied: pycups in /Users/sagara/.pyenv/versions/3.11.2/lib/python3.11/site-packages (2.0.1)

Its maybe cause the device? cause im use M1 not intel or maybe i do wrong in the code?

and i try with terminal and go same error too

Python 3.11.2 (main, Mar 16 2023, 17:42:42) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cups
>>> conn = cups.Connection()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'cups' has no attribute 'Connection'
>>> 
Rofie Sagara
  • 289
  • 5
  • 17
  • When you are running the script and getting the error, is it running in the pyenv, or is it possibly running on a different Python interpreter which isn't including the pyenv modules and is still finding the "incorrect" version of cups? – nigh_anxiety Mar 21 '23 at 04:09
  • Yeah, I try with the terminal too got the same problem, maybe I do in the wrong way? @nigh_anxiety – Rofie Sagara Mar 21 '23 at 05:00
  • In your terminal try `python -c "import sys; print(sys.executable)"` It should output the path to the python.exe in your pyenv virtual environment. If it outputs the base install python.exe instead, then you probably need to activate your virtualenv, and may need to install pycups into the virtualenv. – nigh_anxiety Mar 21 '23 at 14:50

0 Answers0