首页 > 解决方案 > 我无法在 Windows 10 上安装文本

问题描述

我正在尝试在 Windows 10 机器上为 OCR 项目安装 textract,但是在使用pip install textract时,安装失败并显示以下错误消息:

(OcrEnv) C:\Users\Toshiba>pip install textract
Collecting textract
  Using cached https://files.pythonhosted.org/packages/e0/00/a9278b3672a31da06394eb588a16e96f8fce9f6ae0ed44cca18103d4aef5/textract-1.6.1.tar.gz
Collecting argcomplete==1.8.2 (from textract)
  Using cached https://files.pythonhosted.org/packages/f0/0f/f965f1520e6ba24b63320919eecfbe3d03debd32402e0c61a08e8fa02d17/argcomplete-1.8.2-py2.py3-none-any.whl
Requirement already satisfied: chardet==2.3.0 in c:\users\toshiba\anaconda3\lib\site-packages (from textract) (2.3.0)
Collecting python-pptx==0.6.5 (from textract)
  Using cached https://files.pythonhosted.org/packages/f8/9c/30bc244cedc571307efe0780d8195ffed5b08f09c94d23f50d6d5144ebc7/python-pptx-0.6.5.tar.gz
Collecting docx2txt==0.6 (from textract)
  Using cached https://files.pythonhosted.org/packages/aa/72/f02730ec3b0219d8f783a255416339b02ff8b6a300c817abf0505833212a/docx2txt-0.6.tar.gz
Requirement already satisfied: beautifulsoup4==4.5.3 in c:\users\toshiba\anaconda3\lib\site-packages (from textract) (4.5.3)
Requirement already satisfied: xlrd==1.0.0 in c:\users\toshiba\anaconda3\lib\site-packages (from textract) (1.0.0)
Collecting EbookLib==0.15 (from textract)
  Using cached https://files.pythonhosted.org/packages/04/30/2cbf65fa9587a1ecc66a78eea91f9189ead8fdadd5e009115bce34529aa6/EbookLib-0.15.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Public\Documents\Wondershare\CreatorTemp\pip-install-y9tbwmrn\EbookLib\setup.py", line 13, in <module>
        long_description = open('README.md').read(),
      File "c:\users\toshiba\anaconda3\lib\encodings\cp1252.py", line 23, in decode
        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
    UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 1671: character maps to <undefined>

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Public\Documents\Wondershare\CreatorTemp\pip-install-y9tbwmrn\EbookLib\

任何帮助将不胜感激。

标签: python-3.xwindows-10ocr

解决方案


似乎是textract的依赖项之一的问题,ebooklib. 正好textract需要0.15 版。此问题中描述的解决方法是安装和,然后清理 README 中的 Unicode 字符,以便构建可以工作的 0.15 版本:CondaSwigpip

# Run in Python 3.x
with open(r"C:\Users\franc\OneDrive\Pukeko\EbookLib-0.15\README.md", "rb") 
as f:
    text = f.read().decode('ascii', 'replace')

with open(r"C:\Users\franc\OneDrive\Pukeko\EbookLib-0.15\README.md", "w") 
as f:
    print(text, file=f)

您将需要适当地更改这些路径以匹配您的机器。

其他人在使其正常工作时遇到了一些困难,因此如果您仍然遇到问题,您可能需要在该问题中提问。

问题就在这里。


推荐阅读