【问题标题】:Is there anyway to install twain module in python 3无论如何要在python 3中安装twain模块
【发布时间】:2016-01-12 15:06:39
【问题描述】:

我想在 Python 3 中安装 Python TWAIN module。但在文档中它说:

支持 Python 版本 2.1 到 2.5。

我可以使用2to3 转换它吗?

【问题讨论】:

  • 你为什么不试试呢?
  • 请回答并至少用python27完成安装。 2016 我们被困住了
  • @YumYumYum 您可以使用pytwain 模块为python 安装twain 模块。

标签: python twain python-2to3


【解决方案1】:

使用past 模块,该模块提供了一个实验性翻译包,以帮助在 Python 3 环境中导入和使用旧的 Python 2 模块。

所以用 pip 安装你的包

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

并使用下一个代码在您的python3 代码中导入 twain:

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

import twain


# use twain ....... 

【讨论】:

  • 当我尝试这个命令 pip3 install twain --no-compile 时,我收到一条消息: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 这是什么意思?
  • 请回答并完成安装。 2016 我们被困住了
【解决方案2】:

您可以使用.whl 方法为Python 3 安装twain

首先,您需要下载.whl 文件:twainmodule - Python Extension Packages for Windows。选择与您的 Python 3 版本匹配的那个(例如:我下载了twain‑1.0.4‑cp38‑cp38‑win32.whl)。

重要提示,我特地选择了以win32.whl结尾的文件,因为我在使用64位版本时遇到了麻烦。例如,我使用的扫描仪仅支持 32 位 Twain。

然后,安装wheelpip install wheel

使用pip install /path/to/twain‑1.0.4‑cpXX‑cpXX‑XX.whl安装twain

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-23
    • 2022-01-04
    • 1970-01-01
    • 2023-02-07
    • 2016-06-11
    相关资源
    最近更新 更多