openpaperwork / pyinsane Goto Github PK
View Code? Open in Web Editor NEWPython library to access and use image scanners (Linux/Windows/etc) (Sane/WIA) -- Moved to Gnome's Gitlab
Home Page: https://gitlab.gnome.org/World/OpenPaperwork/pyinsane
Python library to access and use image scanners (Linux/Windows/etc) (Sane/WIA) -- Moved to Gnome's Gitlab
Home Page: https://gitlab.gnome.org/World/OpenPaperwork/pyinsane
I am using Python 3.4.0 with the following code (I have not tested with other minor versions):
import pyinsane.abstract as pyinsane
device = pyinsane.Scanner(name='epkowa:net:192.168.1.8')
This works in Python 2.7.6. However, I get the following error in Python 3.4.0:
AttributeError: 'str' object has no attribute 'decode'
I believe the str.decode() method was dropped in Python 3, which is why the error is getting thrown due to this line in the Scanner constructor:
self.name = name.decode('utf-8')
Since a string in Python 3 is already Unicode, perhaps there could just be a check on the parameters to see if they are already Unicode before attempting to decode them?
Hi!
I am thinking of packaging paperwork, which requires pyinsane. To package the latter, it would be nice to have a version number or a versionning scheme.
Any hint ?
Thanks,
Reading or setting any options for Canon P-215 using Python 2.7.10, MacOS Sierra yields this error:
'canon_dr:libusb:020:011' (CANON, P-215, scanner)
Traceback (most recent call last):
File "/Users/Birch/Desktop/untitled 5.py", line 12, in
for opt in device.options.values():
File "/Users/Birch/Envs/sane/lib/python2.7/site-packages/pyinsane2/sane/abstract_proc.py", line 249, in _get_options
options = remote_do("get_options", self.name)
File "/Users/Birch/Envs/sane/lib/python2.7/site-packages/pyinsane2/sane/abstract_proc.py", line 70, in remote_do
assert(len(result) == length)
AssertionError
#!/usr/bin/env python
import pyinsane2
if __name__ == "__main__":
pyinsane2.init()
try:
for device in pyinsane2.get_devices():
print("%s" % (str(device)))
for opt in device.options.values():
print(" Option: %s" % (opt.name))
print(" Title: %s" % (opt.title))
print(" Desc: %s" % (opt.desc))
print(" Type: %s" % (str(opt.val_type)))
print(" Unit: %s" % (str(opt.unit)))
print(" Size: %d" % (opt.size))
print(" Capabilities: %s" % (str(opt.capabilities)))
print(" Constraint type: %s" % (str(opt.constraint_type)))
print(" Constraint: %s" % (str(opt.constraint)))
try:
print(" Value: %s" % (str(opt.value)))
except pyinsane2.PyinsaneException as exc:
# Some scanner allow changing a value, but not reading it.
# For instance Canon Lide 110 allow setting the resolution,
# but not reading it
print(" Value: Failed to get the value: %s" % str(exc))
print("")
finally:
pyinsane2.exit()`
Try to scan from ECOSYS M2535dn
[code]
C:\Python34\lib\site-packages\pyinsane2\wia\rawapi.py:105: RuntimeWarning: Pyinsane: WARNING: A property has a type different from the one expected
properties = _rawapi.get_properties(dev_or_src)
Pyinsane: WARNING: A property has a type different from the one expected
Pyinsane: WARNING: A property has a type different from the one expected
C:\Python34\lib\site-packages\pyinsane2\wia\rawapi.py:116: RuntimeWarning: Pyinsane: WARNING: Got unknown clsid from driver
constraints = _rawapi.get_constraints(dev_or_src)
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Constraint found on property [sti_driver_version] but property not found
Constraint found on property [scan_available_item] but property not found
C:\Python34\lib\site-packages\pyinsane2\wia\rawapi.py:116: RuntimeWarning: Pyinsane: WARNING: Unknown var type for constraint
constraints = _rawapi.get_constraints(dev_or_src)
Pyinsane: WARNING: Unknown var type for constraint
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [preferred_format]
Pyinsane: WARNING: Unknown var type for constraint
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [preferred_format]
C:\Python34\lib\site-packages\pyinsane2\wia\rawapi.py:105: RuntimeWarning: Pyinsane: WARNING: Got unknown clsid from driver
properties = _rawapi.get_properties(dev_or_src)
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: WARNING: Unknown var type for constraint
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [preferred_format]
Pyinsane: WARNING: A property has a type different from the one expected
Pyinsane: WARNING: A property has a type different from the one expected
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Constraint found on property [sti_driver_version] but property not found
Constraint found on property [scan_available_item] but property not found
Pyinsane: WARNING: Unknown var type for constraint
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [preferred_format]
Pyinsane: WARNING: Unknown var type for constraint
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [preferred_format]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: WARNING: Unknown var type for constraint
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [preferred_format]
Got multiple time the option [current_intent], but they are not identical
Got multiple time the option [current_intent], but they are not identical
Option 'current_intent' preset to 'image_type_color,maximize_quality' on ['ECOSYS M2535dn' (Microsoft, Scanning System, scanner,streaming_video)]
Pyinsane: WARNING: A property has a type different from the one expected
Pyinsane: WARNING: A property has a type different from the one expected
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Constraint found on property [sti_driver_version] but property not found
Constraint found on property [scan_available_item] but property not found
Pyinsane: WARNING: Unknown var type for constraint
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [preferred_format]
Pyinsane: WARNING: Unknown var type for constraint
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [preferred_format]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: WARNING: Unknown var type for constraint
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [preferred_format]
Got multiple time the option [current_intent], but they are not identical
Got multiple time the option [current_intent], but they are not identical
Option 'format' preset to 'bmp' on ['ECOSYS M2535dn' (Microsoft, Scanning System, scanner,streaming_video)]
Failed to pre-set option 'preferred_format' on ['ECOSYS M2535dn' (Microsoft, Scanning System, scanner,streaming_video)]
C:\Python34\lib\site-packages\pyinsane2\wia\rawapi.py:127: RuntimeWarning: Pyinsane: WARNING: properties->WriteMultiple() failed
ret = _rawapi.set_property(dev_or_src, propname, propvalue)
Pyinsane: WARNING: properties->WriteMultiple() failed
Pyinsane: WARNING: properties->WriteMultiple() failed: page_size : 0x80070057
Exception while setting page_size: WIA: Failed to set scanner properties
WIA: Failed to set scanner properties
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pyinsane2\wia\abstract.py", line 186, in _set_value
rawapi.set_property(obj, self.name, new_value)
File "C:\Python34\lib\site-packages\pyinsane2\wia\rawapi.py", line 134, in set_property
propname=propname, propvalue=propvalue).wait()
File "C:\Python34\lib\site-packages\pyinsane2\wia\rawapi.py", line 34, in wait
raise self.exception
File "C:\Python34\lib\site-packages\pyinsane2\wia\rawapi.py", line 39, in do
self.result = self.func(**self.kwargs)
File "C:\Python34\lib\site-packages\pyinsane2\wia\rawapi.py", line 129, in _set_property
raise WIAException("Failed to set scanner properties")
pyinsane2.wia.rawapi.WIAException: WIA: Failed to set scanner properties
Pyinsane: WARNING: A property has a type different from the one expected
Pyinsane: WARNING: A property has a type different from the one expected
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Constraint found on property [sti_driver_version] but property not found
Constraint found on property [scan_available_item] but property not found
Pyinsane: WARNING: Unknown var type for constraint
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [preferred_format]
Pyinsane: WARNING: Unknown var type for constraint
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [preferred_format]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: WARNING: Unknown var type for constraint
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [preferred_format]
Got multiple time the option [current_intent], but they are not identical
Got multiple time the option [page_size], but they are not identical
Got multiple time the option [current_intent], but they are not identical
Option 'page_size' preset to 'a4' on ['ECOSYS M2535dn' (Microsoft, Scanning System, scanner,streaming_video)]
Pyinsane: WARNING: A property has a type different from the one expected
Pyinsane: WARNING: A property has a type different from the one expected
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Constraint found on property [sti_driver_version] but property not found
Constraint found on property [scan_available_item] but property not found
Pyinsane: WARNING: Unknown var type for constraint
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [preferred_format]
Pyinsane: WARNING: Unknown var type for constraint
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [preferred_format]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: WARNING: Unknown var type for constraint
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [item_category]
Pyinsane: WARNING: Got unknown clsid from driver
Pyinsane: Failed to parse constraint of [preferred_format]
Got multiple time the option [current_intent], but they are not identical
Got multiple time the option [depth], but they are not identical
Got multiple time the option [page_size], but they are not identical
Got multiple time the option [current_intent], but they are not identical
Got multiple time the option [depth], but they are not identical
Option 'depth' preset to '24' on ['ECOSYS M2535dn' (Microsoft, Scanning System, scanner,streaming_video)]
and the program freezes
Hi
trying to scan in Flatbed mode using Paperwork 1.2.2it says
Error while scanning. No paper to scan
Anyway native Microsoft WDS Driver works perfectly except duplex scanning
This is the list of the both drivers options
epson2.txt
I have an Epson DS-310 document scanner (feeder only, no flatbed). It works fine with sane (scanimage
) and simple-scan
but when I click the scan button in paperwork (1.2.4) it tells me "Scanner not found (is your scanner turned on ?) (error was: <class 'pyinsane2.sane.rawapi.SaneStatus'>: Data is invalid (4))". I installed paperwork via stdeb / pypi-install
on an up-to-date Debian unstable.
I've attached paperwork's diagnostics: paperwork-diagnostics-epson-ds-310.txt
Hallo,
I'm switched from 1.2.1 to the latest version of pyinsane (1.3.1) on a Ubuntu 13.04 64bit (fully updated).
I have an HP OfficeJet 6700 Premium.
Now, when i try to scan from ADF i have this error:
pyinsane.rawapi.SaneException: <class 'pyinsane.rawapi.SaneStatus'> : Error during device I/O (9)
To reproduce this issue simply run :
import pyinsane.abstract as pyinsane
devices = pyinsane.get_devices()
assert(len(devices) > 0)
device = devices[0]
print("I'm going to use the following scanner: %s" % (str(device)))
scanner_id = device.name
if not "ADF" in device.options['source'].constraint:
print("No document feeder found")
else:
device.options['source'].value = "ADF"
# Beware: Some scanner have "Lineart" or "Gray" as default mode
device.options['mode'].value = 'Color'
scan_session = device.scan(multiple=True)
try:
while True:
try:
scan_session.scan.read()
except EOFError:
print ("Got a page ! (current number of pages read: %d)" % (len(scan_session.images)))
except StopIteration:
print("Document feeder is now empty")
for idx in range(0, len(scan_session.images)):
image = scan_session.images[idx]
the output is:
francesco@xyz:~$ python test.py
I'm going to use the following scanner: Scanner 'hpaio:/net/Officejet_6700?ip=192.168.0.99' (Hewlett-Packard, Officejet_6700, all-in-one)
Got a page ! (current number of pages read: 1)
Traceback (most recent call last):
File "test.py", line 20, in <module>
scan_session.scan.read()
File "/usr/local/lib/python2.7/dist-packages/pyinsane/abstract.py", line 289, in read
Scan.read(self)
File "/usr/local/lib/python2.7/dist-packages/pyinsane/abstract.py", line 174, in read
read = rawapi.sane_read(sane_dev_handle[1], SANE_READ_BUFSIZE)
File "/usr/local/lib/python2.7/dist-packages/pyinsane/rawapi.py", line 677, in sane_read
raise SaneException(SaneStatus(status))
pyinsane.rawapi.SaneException: <class 'pyinsane.rawapi.SaneStatus'> : Error during device I/O (9)
Thank you
Packaging pyinsane would require the presence of a full copy of the GPLv3 in the source tree.
Thanks!
Hello everyone,
so I successfully installed pyinsane2 and started to run scan.py in my console (the comand was ..\examples>pyhton scan.py [-h](is '-h' the right thing to do for the first time running?)). The ouput of that was Output file: [Looking for scanners...
pyinsane2\wia\rawapi.py: 72: RuntimeWarning: Pyinsane: Warning: WIADevMgr -> CreateDevice() failed
Failed to access scanner (' {6BDD1FC6-810F-11D0-BEC7-08002BE2092F}\000', 'MX410 series _6277DE000000') : WIA: Failes to open (6BDD1FC6-810F-11D0-BEC7-08002BE2092F).
Whats the problem here? I don't know if the number helps, but I'm hoping that someone might recognizes the order of the numbers and letters and can tell me what kind of number this is, so I could figure out what scanner it is referring and unable to access to.
I get the same error when running [python list_all.py]
I'm running python 3.6 on a windows 8 Computer and don't have WIA2 installed manually, but apprentley that comes with installing pyinsane2...?!
I got past the first compilation issue (missing "atlbase.h") by installing Windows Driver Kit, but now I get too much of a generic error:
` C:>pip3 install pyinsane2
Collecting pyinsane2
Using cached pyinsane2-2.0.2.tar.gz
Requirement already satisfied (use --upgrade to upgrade): Pillow in c:\users\administrator\appdata\local\programs\python\python35-32\lib\site-packages (from pyinsane2)
Installing collected packages: pyinsane2
Running setup.py install for pyinsane2 ... error
Complete output from command c:\users\administrator\appdata\local\programs\python\python35-32\python.exe -u -c "import setuptools, tokenize;file='C:\Users\ADMINI1\AppData\Local\Temp\pip-build-7f56p3zo\pyinsane2\setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record C:\Users\ADMINI1\AppData\Local\Temp\pip-wmnd2g65-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win32-3.5
creating build\lib.win32-3.5\pyinsane2
copying src\pyinsane2\util.py -> build\lib.win32-3.5\pyinsane2
copying src\pyinsane2_init_.py -> build\lib.win32-3.5\pyinsane2
creating build\lib.win32-3.5\pyinsane2\sane
copying src\pyinsane2\sane\abstract.py -> build\lib.win32-3.5\pyinsane2\sane
copying src\pyinsane2\sane\abstract_proc.py -> build\lib.win32-3.5\pyinsane2\sane
copying src\pyinsane2\sane\daemon.py -> build\lib.win32-3.5\pyinsane2\sane
copying src\pyinsane2\sane\rawapi.py -> build\lib.win32-3.5\pyinsane2\sane
copying src\pyinsane2\sane_init_.py -> build\lib.win32-3.5\pyinsane2\sane
creating build\lib.win32-3.5\pyinsane2\wia
copying src\pyinsane2\wia\abstract.py -> build\lib.win32-3.5\pyinsane2\wia
copying src\pyinsane2\wia\rawapi.py -> build\lib.win32-3.5\pyinsane2\wia
copying src\pyinsane2\wia_init_.py -> build\lib.win32-3.5\pyinsane2\wia
running build_ext
building 'pyinsane2.wia._rawapi' extension
creating build\temp.win32-3.5
creating build\temp.win32-3.5\Release
creating build\temp.win32-3.5\Release\src
creating build\temp.win32-3.5\Release\src\pyinsane2
creating build\temp.win32-3.5\Release\src\pyinsane2\wia
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -UNDEBUG -Ic:\winddk\7600.16385.1\inc\atl71 -Ic:\users\administrator\appdata\local\programs\python\python35-32\include -Ic:\users\administrator\appdata\local\programs\python\python35-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program
Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /EHsc /Tpsrc/pyinsane2/wia/properties.cpp /Fobuild\temp.win32-3.5\Release\src/pyinsane2/wia/properties.obj /W4
cl : Command line warning D9025 : overriding '/DNDEBUG' with '/UNDEBUG'
cl : Command line warning D9025 : overriding '/W3' with '/W4'
properties.cpp
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -UNDEBUG -Ic:\winddk\7600.16385.1\inc\atl71 -Ic:\users\administrator\appdata\local\programs\python\python35-32\include -Ic:\users\administrator\appdata\local\programs\python\python35-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program
Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /EHsc /Tpsrc/pyinsane2/wia/rawapi.cpp /Fobuild\temp.win32-3.5\Release\src/pyinsane2/wia/rawapi.obj /W4
cl : Command line warning D9025 : overriding '/DNDEBUG' with '/UNDEBUG'
cl : Command line warning D9025 : overriding '/W3' with '/W4'
rawapi.cpp
c:\winddk\7600.16385.1\inc\atl71\atlcomcli.h(414): warning C4838: conversion from 'int' to 'UINT' requires a narrowing conversion
c:\users\administrator\appdata\local\temp\pip-build-7f56p3zo\pyinsane2\src\pyinsane2\wia\transfer.h(50): error C2695: 'PyinsaneWiaTransferCallback::GetNextStream': overriding virtual function differs from 'IWiaTransferCallback::GetNextStream' only by calling convention
C:\Program Files (x86)\Windows Kits\8.1\include\um\wia_lh.h(2990): note: see declaration of 'IWiaTransferCallback::GetNextStream'
c:\users\administrator\appdata\local\temp\pip-build-7f56p3zo\pyinsane2\src\pyinsane2\wia\transfer.h(51): error C2695: 'PyinsaneWiaTransferCallback::TransferCallback': overriding virtual function differs from 'IWiaTransferCallback::TransferCallback' only by calling convention
C:\Program Files (x86)\Windows Kits\8.1\include\um\wia_lh.h(2986): note: see declaration of 'IWiaTransferCallback::TransferCallback'
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe' failed with exit status 2
----------------------------------------
Command "c:\users\administrator\appdata\local\programs\python\python35-32\python.exe -u -c "import setuptools, tokenize;file='C:\Users\ADMINI1\AppData\Local\Temp\pip-build-7f56p3zo\pyinsane2\setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record C:\Users\ADMINI1\AppData\Local\Temp\pip-wmnd2g65-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\ADMINI~1\AppData\Local\Temp\pip-build-7f56p3zo\pyinsane2`
The problem we're running into is, once a scan is initiated and the image is retrieved, there is no way to garbage collect the now dead session and end the thread safely. It remains alive holding the device hostage. Any attempt to .cancel() or del() the scan/session object results in python hanging/deadlocking.
An strace reveals that it's sitting on a FUTEX_WAIT_PRIVATE:
ioctl(0, SNDCTL_TMR_STOP or SNDRV_TIMER_IOCTL_GINFO or TCSETSW, {B38400 opost isig icanon echo ...}) = 0
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fc3f45b30e0}, {0x7fc3ee3c5a50, [], SA_RESTORER|SA_RESTART, 0x7fc3f45b30e0}, 8) = 0
futex(0x248d0d0, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
It's 100% percent repeatable here:
#!/usr/bin/python2.7
import pyinsane.abstract_th as pyinsane
dev = pyinsane.get_devices()
tmp = dev[0].scan()
try:
while true:
tmp.scan.read()
except EOFError:
pass
tmp.scan.cancel()
#or
tmp.scan.__del__()
Maybe we're not quite understanding how to end and start a new thread/session?
While installing via pip install pyinsane2
returns message
cl : Command line warning D9025 : overriding '/DNDEBUG' with '/UNDEBUG'
properties.cpp
c1xx: fatal error C1083: Cannot open source file: 'pyinsane2/wia/properties.cpp': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2
I understand that it can't find the properties file, but I don't know how to fix this.
Thanks in advance
Hallo,
I'm using an HP Officejet 6700 with Ubuntu 13.10 and the latest Pyinsane.
"Color" and "Gray" scan mode work without problems, but "Lineart" produces messed up images (something like "skewed").
You can verify this issue running your scan.py test program from the sources of pyinsane library (changing scanning mode from 'Color' to 'Lineart' at line 70).
Thank you very much,
Francesco
It will be amazing. Can I get progress of scanning, in this version of library?
see https://github.com/python-imaging/Pillow/blob/master/Sane/sanedoc.txt
Perhaps we could merge effort here.
(Windows only)
Old scanners don't have support for the WIA API. So the Twain API should be supported as well.
Currently there are no tests on ADF support.
I tend to break things.
At least one automated test would be nice (I would have to add a message at the beginning of the tests saying "please insert 4 pages in your ADF" or something like that).
F:\pyinsane>python
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05) [MSC v.1600 32 bit (In
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
import pyinsane.abstract as pyinsane
C:\Python34\lib\importlib_bootstrap.py:1161: UserWarning: Module pyinsane was a
lready imported from C:\Python34\lib\site-packages\pyinsane-1.3.8_git-py3.4.egg
pyinsane__init__.py, but f:\pyinsane is being added to sys.path
spec.loader.load_module(spec.name)
Traceback (most recent call last):
File "", line 1, in
File "", line 2237, in _find_and_load
File "", line 2226, in _find_and_load_unlocked
File "", line 1191, in _load_unlocked
File "", line 1161, in _load_backward_compatible
File "C:\Python34\lib\site-packages\pyinsane-1.3.8_git-py3.4.egg\pyinsane\abst
ract.py", line 5, in
File "", line 2237, in _find_and_load
File "", line 2226, in _find_and_load_unlocked
File "", line 1191, in _load_unlocked
File "", line 1161, in _load_backward_compatible
File "C:\Python34\lib\site-packages\pyinsane-1.3.8_git-py3.4.egg\pyinsane\rawa
pi.py", line 440, in
NameError: name 'SANE_LIB' is not defined
hi, I don't know why 'name 'SANE_LIB' is not defined'
did I miss something?
Everything is working fine with my pyinsane2 module, I just want to change the saving location of the scanned document, because right now, the document gets stored in the folder your script, that you run to scan, is stored in as well. This comes from line 107 in scan.py
: img.save(output_file, "JPEG")
.
Any tips on what to change for a specific location?
And also, but I don't think this is very important, what does "JPEG" stand for in this case(I know this stands for an image ending, but what particular)? I can type in test.pdf and a pdf document will be created.
Hi everyone,
I'm trying to scan duplex cards with my scanner (fi 7160) in Windows 10, but all that I get is images like this:
The output of list_all is:
pyinsane2/wia/rawapi.cpp(L422): A property has a type different from the one expected
pyinsane2/wia/properties.cpp(L866): Got unknown clsid from driver (property=item_category)
pyinsane2/wia/rawapi.cpp(L568): Failed to parse constraint of [item_category]
Constraint found on property [sti_driver_version] but property not found
pyinsane2/wia/rawapi.cpp(L563): Unknown var type for constraint
pyinsane2/wia/properties.cpp(L866): Got unknown clsid from driver (property=item_category)
pyinsane2/wia/rawapi.cpp(L568): Failed to parse constraint of [item_category]
pyinsane2/wia/properties.cpp(L866): Got unknown clsid from driver (property=preferred_format)
pyinsane2/wia/rawapi.cpp(L568): Failed to parse constraint of [preferred_format]
pyinsane2/wia/rawapi.cpp(L422): A property has a type different from the one expected
pyinsane2/wia/properties.cpp(L866): Got unknown clsid from driver (property=item_category)
pyinsane2/wia/rawapi.cpp(L568): Failed to parse constraint of [item_category]
Constraint found on property [sti_driver_version] but property not found
pyinsane2/wia/rawapi.cpp(L563): Unknown var type for constraint
pyinsane2/wia/properties.cpp(L866): Got unknown clsid from driver (property=item_category)
pyinsane2/wia/rawapi.cpp(L568): Failed to parse constraint of [item_category]
pyinsane2/wia/properties.cpp(L866): Got unknown clsid from driver (property=preferred_format)
pyinsane2/wia/rawapi.cpp(L568): Failed to parse constraint of [preferred_format]
Option 'current_intent' preset to 'image_type_color,maximize_quality' on ['fi-7160' (FUJITSU, fi-7160, scanner,streaming_video)]
pyinsane2/wia/rawapi.cpp(L422): A property has a type different from the one expected
pyinsane2/wia/properties.cpp(L866): Got unknown clsid from driver (property=item_category)
pyinsane2/wia/rawapi.cpp(L568): Failed to parse constraint of [item_category]
Constraint found on property [sti_driver_version] but property not found
pyinsane2/wia/rawapi.cpp(L563): Unknown var type for constraint
pyinsane2/wia/properties.cpp(L866): Got unknown clsid from driver (property=item_category)
pyinsane2/wia/rawapi.cpp(L568): Failed to parse constraint of [item_category]
pyinsane2/wia/properties.cpp(L866): Got unknown clsid from driver (property=preferred_format)
pyinsane2/wia/rawapi.cpp(L568): Failed to parse constraint of [preferred_format]
Option 'format' preset to 'bmp' on ['fi-7160' (FUJITSU, fi-7160, scanner,streaming_video)]
Failed to pre-set option 'preferred_format' on ['fi-7160' (FUJITSU, fi-7160, scanner,streaming_video)]
pyinsane2/wia/rawapi.cpp(L644): Setting property [page_size]: properties->WriteMultiple() failed
Unexpected exception
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe1 in position 69: invalid continuation byte
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\NewPc\AppData\Local\Programs\Python\Python36\lib\logging_init_.py", line 1317, in warning
if self.isEnabledFor(WARNING):
File "C:\Users\NewPc\AppData\Local\Programs\Python\Python36\lib\logging_init_.py", line 1548, in isEnabledFor
return level >= self.getEffectiveLevel()
SystemError: PyEval_EvalFrameEx returned a result with an error set
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\NewPc\AppData\Local\Programs\Python\Python36\lib\site-packages\pyinsane2\wia\rawapi.py", line 58, in do
self.result = self.func(**self.kwargs)
File "C:\Users\NewPc\AppData\Local\Programs\Python\Python36\lib\site-packages\pyinsane2\wia\rawapi.py", line 150, in _set_property
ret = _rawapi.set_property(dev_or_src, propname, propvalue)
SystemError: returned a result with an error set
Failed to pre-set option 'page_size' on ['fi-7160' (FUJITSU, fi-7160, scanner,streaming_video)]
pyinsane2/wia/rawapi.cpp(L422): A property has a type different from the one expected
pyinsane2/wia/properties.cpp(L866): Got unknown clsid from driver (property=item_category)
pyinsane2/wia/rawapi.cpp(L568): Failed to parse constraint of [item_category]
Constraint found on property [sti_driver_version] but property not found
pyinsane2/wia/rawapi.cpp(L563): Unknown var type for constraint
pyinsane2/wia/properties.cpp(L866): Got unknown clsid from driver (property=item_category)
pyinsane2/wia/rawapi.cpp(L568): Failed to parse constraint of [item_category]
pyinsane2/wia/properties.cpp(L866): Got unknown clsid from driver (property=preferred_format)
pyinsane2/wia/rawapi.cpp(L568): Failed to parse constraint of [preferred_format]
Option 'depth' preset to '24' on ['fi-7160' (FUJITSU, fi-7160, scanner,streaming_video)]
pyinsane2/wia/rawapi.cpp(L224): WiaDevMgr->CreateDevice() failed
pyinsane2/wia/rawapi.cpp(L225): HResult error code 0x80210005: Unknown error 0x80210005
Unexpected exception
Traceback (most recent call last):
File "C:\Users\NewPc\AppData\Local\Programs\Python\Python36\lib\site-packages\pyinsane2\wia\rawapi.py", line 58, in do
self.result = self.func(**self.kwargs)
File "C:\Users\NewPc\AppData\Local\Programs\Python\Python36\lib\site-packages\pyinsane2\wia\rawapi.py", line 97, in _open
raise WIAException("Failed to open {}".format(devid))
pyinsane2.wia.rawapi.WIAException: WIA: Failed to open {6BDD1FC6-810F-11D0-BEC7-08002BE2092F}\0000
Failed to access scanner ('{6BDD1FC6-810F-11D0-BEC7-08002BE2092F}\0000', 'EPSON Perfection V600') : WIA: Failed to open {6BDD1FC6-810F-11D0-BEC7-08002BE2092F}\0000
WIA: Failed to open {6BDD1FC6-810F-11D0-BEC7-08002BE2092F}\0000
Traceback (most recent call last):
File "C:\Users\NewPc\AppData\Local\Programs\Python\Python36\lib\site-packages\pyinsane2\wia\abstract.py", line 629, in get_devices
scanner = Scanner(dev[0])
File "C:\Users\NewPc\AppData\Local\Programs\Python\Python36\lib\site-packages\pyinsane2\wia\abstract.py", line 451, in init
self._dev = rawapi.open(name)
File "C:\Users\NewPc\AppData\Local\Programs\Python\Python36\lib\site-packages\pyinsane2\wia\rawapi.py", line 102, in open
return WiaAction(_open, devid=devid).wait()
File "C:\Users\NewPc\AppData\Local\Programs\Python\Python36\lib\site-packages\pyinsane2\wia\rawapi.py", line 50, in wait
raise self.exception
File "C:\Users\NewPc\AppData\Local\Programs\Python\Python36\lib\site-packages\pyinsane2\wia\rawapi.py", line 58, in do
self.result = self.func(**self.kwargs)
File "C:\Users\NewPc\AppData\Local\Programs\Python\Python36\lib\site-packages\pyinsane2\wia\rawapi.py", line 97, in _open
raise WIAException("Failed to open {}".format(devid))
pyinsane2.wia.rawapi.WIAException: WIA: Failed to open {6BDD1FC6-810F-11D0-BEC7-08002BE2092F}\0000
'fi-7160' (FUJITSU, fi-7160, scanner,streaming_video)
Option: firmware_version
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 0500
Option: access_rights
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: [3, 3]
Value: read,write,read_can_be_deleted,read_write_can_be_deleted
Option: full_item_name
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 0001\Root\Feeder
Option: item_category
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: ['root', 'flatbed', 'feeder', 'feeder_front', 'feeder_back', 'film', 'folder', 'finished_file']
Value: feeder
Option: item_flags
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: free
Value: file,image,programmable_data_source,transfer
Option: item_name
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: Feeder
Option: dev_id
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: {6BDD1FC6-810F-11D0-BEC7-08002BE2092F}\0001
Option: vend_desc
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: FUJITSU
Option: dev_desc
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: fi-7160
Option: dev_type
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: default
Value: scanner,streaming_video
Option: port_name
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: \.\Usbscan0
Option: dev_name
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: fi-7160
Option: server_name
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: local
Option: remote_dev_id
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value:
Option: ui_clsid
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: {CDB3A172-0821-4246-9F5F-5E41A9767EDE}
Option: hw_config
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: ['generic', 'scsi', 'usb', 'serial', 'parallel']
Value: 0
Option: baudrate
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value:
Option: sti_gen_capabilities
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 51
Option: wia_version
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 2.0
Option: driver_version
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 2.0.1.2
Option: pnp_id
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: \?\usb#vid_04c5&pid_132e#5&1c33cd9e&0&18#{6bdd1fc6-810f-11d0-bec7-08002be2092f}
Option: document_handling_capabilities
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: ['auto_source', 'dup', 'detect_film_tpa', 'detect_stor', 'film_tpa', 'stor', 'detect_feed', 'detect_flat', 'detect_scan', 'dup', 'feed', 'flat', 'detect_dup', 'detect_dup_avail', 'detect_feed_avail']
Value: dup,feed
Option: document_handling_status
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: ['feed_ready', 'flat_ready', 'dup_ready', 'flat_cover_up', 'path_cover_up', 'paper_jam', 'film_tpa_ready', 'storage_ready', 'storage_full', 'multiple_feed', 'device_attention', 'lamp_err']
Value: feed_ready,dup_ready
Option: user_name
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: DESKTOP-HLEBMBT\NewPc
Value: DESKTOP-HLEBMBT\NewPc
Option: bits_per_channel
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 8
Option: buffer_size
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 65536
Option: channels_per_pixel
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 3
Option: compression
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: [0, 0, 1]
Value: none
Option: datatype
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: [0, 2, 3, 3, 3]
Value: color
Option: depth
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: [1, 24, 24]
Value: 24
Option: filename_extension
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: BMP
Option: format
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: ['bmp', 'ciff', 'exif', 'flashpix', 'gif', 'ico', 'jbig', 'jpeg', 'jpeg2k', 'jpeg2kx', 'memorybmp', 'pdfa', 'photocd', 'pict', 'png', 'raw', 'rawrgb', 'tiff']
Value: bmp
Option: icm_profile_name
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: ['', 'sRGB Color Space Profile.icm', 'sRGB Color Space Profile.icm']
Value: sRGB Color Space Profile.icm
Option: item_size
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 0
Option: number_of_lines
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 2100
Option: pixels_per_line
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 1275
Option: planar
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: pixel
Value: pixel
Option: preferred_format
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: ['bmp', 'ciff', 'exif', 'flashpix', 'gif', 'ico', 'jbig', 'jpeg', 'jpeg2k', 'jpeg2kx', 'memorybmp', 'pdfa', 'photocd', 'pict', 'png', 'raw', 'rawrgb', 'tiff']
Value: bmp
Option: tymed
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: [1, 2, 2]
Value: file
Option: document_handling_select
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: [32, 36]
Value: front_only
Option: optical_xres
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 600
Option: optical_yres
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 600
Option: page_height
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 14000
Option: page_size
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: [1, 2, 2]
Value: custom
Option: page_width
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 8500
Option: pages
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: (0, 1)
Value: 1
Option: scan_ahead_pages
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: (0, 100)
Value: 100
Option: sheet_feeder_registration
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: left_justified
Value: centered
Option: show_preview_control
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: show_preview_control
Value: dont_show_preview_control
Option: brightness
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: (-128, 0)
Value: 0
Option: contrast
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: (-128, 0)
Value: 0
Option: current_intent
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: [0, 458759]
Value: image_type_color,image_type_mask,maximize_quality,size_mask
Option: max_horizontal_size
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 8500
Option: max_vertical_size
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 14000
Option: min_horizontal_size
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 2000
Option: min_vertical_size
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 2000
Option: orientation
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: [0, 0, 1]
Value: portrait
Option: photometric_interp
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: [0, 0, 1]
Value: white_1
Option: rotation
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: [0, 0, 1]
Value: portrait
Option: supportes_child_item_creation
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: ro
Constraint type: None
Constraint: None
Value: 0
Option: threshold
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: (1, 128)
Value: 128
Option: xextent
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: (300, 1275)
Value: 1275
Option: xpos
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: (0, 0)
Value: 0
Option: xres
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: (75, 150)
Value: 150
Option: yextent
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: (300, 2100)
Value: 2100
Option: ypos
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: (0, 0)
Value: 0
Option: yres
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: (75, 150)
Value: 150
Option: tl-x
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: (0, 1275)
Value: 0
Option: br-x
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: (0, 1275)
Value: 1275
Option: tl-y
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: (0, 2100)
Value: 0
Option: br-y
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: (0, 2100)
Value: 2100
Option: resolution
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: (75, 150)
Value: 150
Option: source
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: ['0001\Root\Feeder']
Value: 0001\Root\Feeder
Option: mode
Title:
Desc:
Type: None
Unit: None
Size: 4
Capabilities: Access: rw
Constraint type: None
Constraint: ['Color', 'Gray', 'BW']
Value: Color
What should I try?
Thanks in advance
In the file abstract.py at line 216, there is a "sys" wrong instruction for python 2.6.
if sys.version_info.major < 3:
In python 2.6 sys.version_info is a tuple and version_info hasn't attribute major.
The following command is good for all python version.
sys.version_info[0]
I'm on Fedora 27, and if I use the scripts with sudo, everything works. Without sudo it gives me:
`...
process 6828: arguments to dbus_connection_send() were incorrect, assertion "connection != NULL" failed in file dbus-connection.c line 3308.
This is normally a bug in some application using the D-Bus library.
D-Bus not built with -rdynamic so unable to print a backtrace
Traceback (most recent call last):
File "custom.py", line 7, in
devices = pyinsane2.get_devices()
File "/home/nikolai/anaconda3/lib/python3.6/site-packages/pyinsane2/sane/abstract_proc.py", line 278, in get_devices
for x in remote_do('get_devices', local_only)
File "/home/nikolai/anaconda3/lib/python3.6/site-packages/pyinsane2/sane/abstract_proc.py", line 68, in remote_do
length = struct.unpack("i", length)[0]
struct.error: unpack requires a buffer of 4 bytes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "custom.py", line 35, in
pyinsane2.exit()
File "/home/nikolai/anaconda3/lib/python3.6/site-packages/pyinsane2/sane/abstract_proc.py", line 130, in exit
remote_do('exit')
File "/home/nikolai/anaconda3/lib/python3.6/site-packages/pyinsane2/sane/abstract_proc.py", line 64, in remote_do
os.write(fifo_c2s, length)
BrokenPipeError: [Errno 32] Broken pipe
`
Honestly is driving me crazy for the last 2 days :(
When a program uses abstrat_th and halts, it segfaults.
What happens:
The problem comes from either libsane + threads or ctypes + threads.
This is a really minor issue, since the program is pretty much finished when it happens. Still, segfaults are not good features :p
======== RESTART: /home/pi/Downloads/pyinsane-stable/examples/scan.py ========
Output file: /home/pi/Documents/LinearBookScanner/test.jpg
Looking for scanners ...
Devices detected:
Will use: 'genesys:libusb:001:005' (Canon, LiDE 120, flatbed scanner)
Unable to set scanner option [source]: Option is not active
Scanning ...
�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�|�/�-�\�
Writing output file ...
Traceback (most recent call last):
File "/home/pi/Downloads/pyinsane-stable/examples/scan.py", line 113, in
main()
File "/home/pi/Downloads/pyinsane-stable/examples/scan.py", line 105, in main
img = scan_session.images[0]
File "/usr/local/lib/python3.5/dist-packages/pyinsane2/sane/abstract_proc.py", line 202, in __get_imgs
imgs = remote_do('get_images', self._scanner)
File "/usr/local/lib/python3.5/dist-packages/pyinsane2/sane/abstract_proc.py", line 68, in remote_do
length = struct.unpack("i", length)[0]
struct.error: unpack requires a bytes object of length 4
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/Downloads/pyinsane-stable/examples/scan.py", line 115, in
pyinsane2.exit()
File "/usr/local/lib/python3.5/dist-packages/pyinsane2/sane/abstract_proc.py", line 120, in exit
remote_do('exit')
File "/usr/local/lib/python3.5/dist-packages/pyinsane2/sane/abstract_proc.py", line 56, in remote_do
os.write(fifo_c2s, length)
BrokenPipeError: [Errno 32] Broken pipe
Does support scanners (probably an ADF type) for simultaneous two-sided scanning?
Great project btw!
Thanks.
My network scanner is not detected.
I've found the following message talking about network scanner detection, in another context. I've understood that the second argument to sane_get_devices needs to be "false" in order to enable network scanner detection :
http://lists.alioth.debian.org/pipermail/sane-devel/2003-February/006603.html
So in rawapi.py
I've changed line 519 from :
def sane_get_devices(remote=True):
to :
def sane_get_devices(remote=False):
Now, paperwork correctly finds my network scanner. But scanner detection is slower.
I don't know if this solution can be made as default, I don't know if there is any other result when modifying this...
The Brother MFC-495CW (using the brscan3 drivers) has 3 possible sources:
Currently, Pyinsane only looks for a source called "ADF".
The end result is that it reads the first document, then feeds the rest without reading. The tests end stuck in an infinite loop.
Hi there,
I am trying to automate sccanning a batch of document with a script in python using Pyinsane2. But when I Call the scan_session = device.scan(multiple=True) routine I get the mesage "Pyinsane: Stream::QueryInterface(): Unknown interface requested" several times, and the python and if i press enter it returns an empty scan_sessions.images, and doesn't proceed to the next sheet.
I am using python 3.6 in a Windows 10 with WIA2, the scanner is a Lexmark all-in-one Mx410de and the connection is over lan.
Any guesses on How to fix this? Thanks
Hello,
when running any of the files of this rep, after I have succssefully build and installed the setup.py file, it gives me ModuleNotFoundError: NO module named 'pyinsane2'.
Has anyone experienced this before or can help me with fixing this ?
The module is listed under installed modules and it is added to my SYS.PATH.
With the device Brother MVC-J410 the follow line of code produce the follow error masage.
device.options['mode'].value = 'Color'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/pyinsane/abstract.py", line 95, in _set_value
rawapi.sane_set_option_value(sane_dev_handle[1], self.idx, new_value)
File "/usr/local/lib/python2.7/dist-packages/pyinsane/rawapi.py", line 632, in sane_set_option_value
raise SaneException(SaneStatus(status))
pyinsane.rawapi.SaneException: <class 'pyinsane.rawapi.SaneStatus'> : Data is invalid (4)
Hello
I'm trying to use Paperwork 1.2.4-20-ga29c3cb on Linux Mint 18.1 Cinnamon 64 Bit. The Brother DCP-130C works fine with Simple Scan but not with Paperwork. I get the following error. Is there a work around?
INFO paperwork.frontend.util.actions Action: [Scan a single page]
INFO paperwork.frontend.util.config Will scan using net:127.0.0.1:brother2:bus2;dev1
WARNING paperwork.frontend.util.config Exception while configuring scanner: <class 'pyinsane2.sane.rawapi.SaneException'>: <class 'pyinsane2.sane.rawapi.SaneStatus'> : Data is invalid (4)
ERROR paperwork.frontend.util.config <class 'pyinsane2.sane.rawapi.SaneStatus'> : Data is invalid (4)
Traceback (most recent call last):
Cheers Ivan
git clone https://github.com/plietar/pyinsane pyinsanetest
cd pyinsanetest
git rev-parse HEAD
75f49f316d20b588610441239bb9fc4c64411e25
gdb --args python ./run_tests.py
GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python...Reading symbols from /usr/lib/debug//usr/bin/python2.7...done.
done.
(gdb) r
Starting program: /usr/bin/python ./run_tests.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff596c700 (LWP 11939)]
=== RawAPI: ===
test_init (tests.tests_rawapi.TestSaneInit) ... ok
test_get_devices (tests.tests_rawapi.TestSaneGetDevices) ... [New Thread 0x7fffeffff700 (LWP 11940)]
[New Thread 0x7fffe59bb700 (LWP 11941)]
ok
test_open_invalid (tests.tests_rawapi.TestSaneOpen) ... ok
test_open_valid (tests.tests_rawapi.TestSaneOpen) ... ok
test_get_option_descriptor_0 (tests.tests_rawapi.TestSaneGetOptionDescriptor) ... FAIL
test_get_option_descriptor_out_of_bounds (tests.tests_rawapi.TestSaneGetOptionDescriptor) ... ok
test_get_option_value (tests.tests_rawapi.TestSaneControlOption) ... ok
test_set_option_value (tests.tests_rawapi.TestSaneControlOption) ...
Program received signal SIGSEGV, Segmentation fault.
subtype_dealloc.lto_priv () at ../Objects/typeobject.c:1015
1015 ../Objects/typeobject.c: No such file or directory.
I wasn't sure if I should submit this as an issue because I don't know if this a problem with my code or the pyinsane library. I'm building a Qt (PySide) GUI application and utilizing threading through the QThread class. I am using the pyinsane.abstract_th module for scanning.
I am able to execute a scan successfully when pushing a button on my application. After the scan completes, I can execute another scan. The problem is the third attempt at execution, which hangs indefinitely. It hangs when attempting to set options for the scan. Here is the snippet of code where the hanging occurs:
def _get_scanner():
print('Inside _get_scanner()')
scanner_name = 'epkowa:net:192.168.1.8'
return pyinsane.Scanner(name=scanner_name)
def scan(mode=None,res=None,source=None,filename=None):
print('Inside scan()')
scanner = _get_scanner()
#For Testing
devices = pyinsane.get_devices()
if (len(devices) <= 0):
print('No scanner detected!')
sys.exit(1)
print('Devices detected:')
print('- ' + '\n- '.join([str(d) for d in devices]))
print('Setting scan options...')
# HANGS AFTER PRINTING THE ABOVE LINE
try:
scanner.options['resolution'].value = res
except (KeyError, pyinsane.SaneException) as exc:
print('Failed to set %s to %s: %s' % ('resolution', str(res), str(exc)))
I noticed that when I retrieve the available devices, my network scanner (epkowa:net:192.168.1.8) is found the first execution, but then is not in subsequent executions (button pushes). However, even though it is not found in the second attempt, the scan still completes successfully.
I have also tried this with the pyinsane.abstract module, which will execute one scan just fine. However, on additional attempts I get the following error after executing scanner.scan(multiple=False):
Traceback (most recent call last):
File "main.py", line 90, in process
docscan.scan(self.mode, self.res, self.source, self.filename)
File "/home/dev/python_projects/scanimage_gui/docscan.py", line 38, in scan
scan_session = scanner.scan(multiple=False)
File "/home/dev/python_projects/scanimage_gui/pyinsane/abstract.py", line 455, in scan
scan = SingleScan(self)
File "/home/dev/python_projects/scanimage_gui/pyinsane/abstract.py", line 273, in __init__
self._init()
File "/home/dev/python_projects/scanimage_gui/pyinsane/abstract.py", line 175, in _init
rawapi.sane_start(sane_dev_handle[1])
File "/home/dev/python_projects/scanimage_gui/pyinsane/rawapi.py", line 674, in sane_start
raise SaneException(SaneStatus(status))
pyinsane.rawapi.SaneException: <class 'pyinsane.rawapi.SaneStatus'> : Error during device I/O (9)
I have tried deleting the Qt worker and thread objects in my PySide application after the scan completes to make sure the thread has released its handle on the scanner, but that doesn't seem to make a difference.
Again, I'm not sure where the issue lies, but I thought I would at least throw this out to narrow down the problem. By the way, everything works correctly when not using threading. I can execute as many scan operations as I want. I want to use threading, though, due to GUI blocking issues in my Qt app.
Please let me know if you would like additional code to review.
Thanks!
Hi,
I installed this library and testing it on my OS X.
Everything is ok for the installation.
When i try to make a demo code.
import pyinsane.abstract as pyinsane
devices = pyinsane.get_devices()
Traceback (most recent call last):
File "", line 1, in
File "build/bdist.macosx-10.11-x86_64/egg/pyinsane/abstract.py", line 473, in get_devices
File "build/bdist.macosx-10.11-x86_64/egg/pyinsane/rawapi.py", line 522, in sane_init
AssertionError
Can you have a look on this one?
I have a use case where I need to scan 2 different scanners at the same time. when I attempt to multi thread pyinsane2 I get the following
TestScanMultiple.txt
error. attached is the python script that generated this error. Any help would be greatly appreciated.
===== RESTART: /home/pi/Documents/LinearBookScanner/TestScanMultiple.py =====
Device Id: 0Device Id: 1
init in thread: 1init in thread: 2
Devices Recieved in thread: 2
Exiting in thread: 2
Exception in thread Thread-1:
Traceback (most recent call last):
File "/home/pi/Documents/LinearBookScanner/TestScanMultiple.py", line 12, in Scan
devices = pyinsane2.get_devices()
File "/usr/local/lib/python3.5/dist-packages/pyinsane2/sane/abstract_proc.py", line 268, in get_devices
for x in remote_do('get_devices', local_only)
File "/usr/local/lib/python3.5/dist-packages/pyinsane2/sane/abstract_proc.py", line 69, in remote_do
result = os.read(fifo_s2c, length)
OSError: [Errno 9] Bad file descriptor
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/home/pi/Documents/LinearBookScanner/TestScanMultiple.py", line 16, in Scan
pyinsane2.exit()
File "/usr/local/lib/python3.5/dist-packages/pyinsane2/sane/abstract_proc.py", line 120, in exit
remote_do('exit')
File "/usr/local/lib/python3.5/dist-packages/pyinsane2/sane/abstract_proc.py", line 56, in remote_do
os.write(fifo_c2s, length)
OSError: [Errno 9] Bad file descriptor
After a long wait:
INFO Building report ...
INFO * User info
INFO * Scanner settings
INFO No image attached to report
INFO * System configuration
INFO * Scan test result
INFO * User comment
INFO * Traces
INFO Report ready: 24961 Kbytes to send
INFO Connecting to openpaper.work
INFO Posting report...
INFO Please wait, this may take a while...
ERROR Error from server: 500 - Internal Server Error
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.