2

I want to install the Python TWAIN module in Python 3. But in the docs it says:

Python versions 2.1 through 2.5 are supported.

Can I convert it using 2to3?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Cahit Yıldırım
  • 499
  • 1
  • 10
  • 26

2 Answers2

0

Use past module which provides an experimental translation package to help with importing and using old Python 2 modules in a Python 3 environment.

So install your package with pip

pip3 install twain --no-compile   # to ignore SyntaxErrors

And use next code to import twain in your python3 code :

from past import autotranslate
autotranslate(['twain'])

import twain


# use twain ....... 
Andriy Ivaneyko
  • 20,639
  • 6
  • 60
  • 82
  • When I try this command `pip3 install twain --no-compile` , I have got an message like : `Downloading/unpacking twain Could not find any downloads that satisfy the requirement twain Cleaning up... No distributions at all found for twain Storing debug log for failure in C:\Users\PB\pip\pip.log` What does it mean? – Cahit Yıldırım Jan 13 '16 at 23:56
  • Please answer and complete the installation. 2016 we are stuck –  Apr 04 '16 at 06:02
0

You can install twain for Python 3 using the .whl method.

First, you need to download the .whl file: twainmodule - Python Extension Packages for Windows. Pick the one that matches your Python 3 version (example: I downloaded the twain‑1.0.4‑cp38‑cp38‑win32.whl).

Important note, I specifically chose the file ending with win32.whl because I had troubles using the 64-bit version. For example, the scaner I was working with only supported 32-bit Twain.

Then, install wheel with pip install wheel.

Install twain using pip install /path/to/twain‑1.0.4‑cpXX‑cpXX‑XX.whl

Martin
  • 884
  • 7
  • 16