openpaperwork / pyinsane

Python library to access and use image scanners (Linux/Windows/etc) (Sane/WIA) -- Moved to Gnome's Gitlab
https://gitlab.gnome.org/World/OpenPaperwork/pyinsane
63 stars 24 forks source link

name 'SANE_LIB' is not defined #18

Closed xinyu3ru closed 9 years ago

xinyu3ru commented 9 years ago

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\ pyinsaneinit.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?

jflesch commented 9 years ago

1) You need to know that Pyinsane doesn't support Windows (I have no Windows license).

2) Even if it would, Sane on Windows only supports network scanners (--> they must be hosted by a Linux machine if I'm not mistaken).

3) There is actually a bug in Pyinsane:

try:
    SANE_LIB = ctypes.cdll.LoadLibrary("libsane.so.1")
    sane_available = True
except OSError:
    sane_available = False
(...)
SANE_LIB.sane_init.argtypes = [ctypes.POINTER(ctypes.c_int), AUTH_CALLBACK_DEF]
SANE_LIB.sane_init.restype = ctypes.c_int

^ Pyinsane should actually load. It's just that the function is_sane_available() should return False. I'll fix that asap.

jflesch commented 9 years ago

Fixed: ebb4933f3222872c669441155e7003a025405602

xinyu3ru commented 9 years ago

Thanks and feel sorry about made a trouble。