Conda 不会安装 pdfplumber

Conda wont install pdfplumber

我正在尝试使用 miniconda3 安装 pdfplumber。我不断收到此错误消息,但我不知道如何解释它。

(env1) C:\Users\engineer>conda install -c conda-forge pdfplumber
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: -
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed

UnsatisfiableError: The following specifications were found to be incompatible with each other:

Output in format: Requested package -> Available versions
Note that strict channel priority may have removed packages required for satisfiability.

另外:

(env1) C:\Users\engineer>conda info

 active environment : env1
active env location : C:\tools\miniconda3\envs\env1
        shell level : 2
   user config file : C:\Users\engineer\.condarc  populated config files : C:\Users\engineer\.condarc
      conda version : 4.10.3
conda-build version : not installed
     python version : 3.8.10.final.0
   virtual packages : __cuda=10.2=0
                      __win=0=0
                      __archspec=1=x86_64
   base environment : C:\tools\miniconda3  (writable)
  conda av data dir : C:\tools\miniconda3\etc\conda   conda av metadata url : None
       channel URLs : https://conda.anaconda.org/conda-forge/win-64
                      https://conda.anaconda.org/conda-forge/noarch
                      https://repo.anaconda.com/pkgs/main/win-64
                      https://repo.anaconda.com/pkgs/main/noarch
                      https://repo.anaconda.com/pkgs/r/win-64
                      https://repo.anaconda.com/pkgs/r/noarch
                      https://repo.anaconda.com/pkgs/msys2/win-64
                      https://repo.anaconda.com/pkgs/msys2/noarch
      package cache : C:\tools\miniconda3\pkgs
                      C:\Users\engineer\.conda\pkgs
                      C:\Users\engineer\AppData\Local\conda\conda\pkgs
   envs directories : C:\tools\miniconda3\envs
                      C:\Users\engineer\.conda\envs
                      C:\Users\engineer\AppData\Local\conda\conda\envs
           platform : win-64
         user-agent : conda/4.10.3 requests/2.26.0 CPython/3.8.10 Windows/10 Windows/10.0.18363
      administrator : False
         netrc file : None
       offline mode : False

使用 pip 不是一个选项,因为它绝对不能在我的公司代理后面工作,而 miniconda3 可以。

没有用于 win-64 的 ImageMagick

另一个 Conda 在识别不可满足性问题方面很糟糕的案例。 Mamba 对此做得很好,确定 imagemagick 包不适用于 win-64 平台:

$ CONDA_SUBDIR="win-64" mamba create -dn foo -c conda-forge pdfplumber

                  __    __    __    __
                 /  \  /  \  /  \  /  \
                /    \/    \/    \/    \
███████████████/  /██/  /██/  /██/  /████████████████████████
              /  / \   / \   / \   / \  \____
             /  /   \_/   \_/   \_/   \    o \__,
            / _/                       \_____/  `
            |/
        ███╗   ███╗ █████╗ ███╗   ███╗██████╗  █████╗
        ████╗ ████║██╔══██╗████╗ ████║██╔══██╗██╔══██╗
        ██╔████╔██║███████║██╔████╔██║██████╔╝███████║
        ██║╚██╔╝██║██╔══██║██║╚██╔╝██║██╔══██╗██╔══██║
        ██║ ╚═╝ ██║██║  ██║██║ ╚═╝ ██║██████╔╝██║  ██║
        ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝ ╚═╝  ╚═╝

        mamba (0.15.2) supported by @QuantStack

        GitHub:  https://github.com/mamba-org/mamba
        Twitter: https://twitter.com/QuantStack

█████████████████████████████████████████████████████████████


Looking for: ['pdfplumber']

bioconda/win-64          [====================] (00m:00s) No change
pkgs/main/noarch         [====================] (00m:00s) Done
pkgs/r/win-64            [====================] (00m:00s) Done
pkgs/r/noarch            [====================] (00m:00s) No change
pkgs/main/win-64         [====================] (00m:00s) Done
bioconda/noarch          [====================] (00m:01s) Done
conda-forge/noarch       [====================] (00m:01s) Done
conda-forge/win-64       [====================] (00m:02s) Done
Encountered problems while solving:
  - nothing provides imagemagick needed by wand-0.5.6-py_0

可能的解决方法

它应该可以在您的系统上本地安装 ImageMagick,并确保可以从命令行访问它。然后,您可以创建一个带有强制安装的 wand 包的环境,这是唯一依赖于 ImageMagick 的包。

以下是创建环境的步骤(下面称为 my_env,但可以随意命名):

## create the environment with python (I think you can use 3.6+)
conda create -n my_env python=3.9

## force-install "wand"
conda install -n my_env --no-deps wand=0.6.5

## install pdfplumber
conda install -n my_env pdfplumber

## try using the environment
conda activate my_env

补充说明

不需要 ImageMagick。 从技术上讲,ImageMagick 似乎只用于 the "Visual Debugging" functionality of pdfplumber。如果您不需要它,那么您可以完全放弃安装 ImageMagick。我验证了(在 osx-64 上)没有 ImageMagick 的上述环境可以 运行 CLI 示例和第一个 Python API 来自 pdfplumber 文档的示例。

使用隔离环境。 因为强制安装可能很危险(阅读 --no-deps 标志上的 conda install --help),我强烈建议创建一个专用的环境如上图

为什么固定 wand 版本? 我为 wand 指定了一个版本,因为这将有助于防止 Conda 在将来尝试更改它正在更新。

Mamba 很棒。 我强烈推荐使用 Mamba。安装简单:

conda install -n base -c conda-forge mamba

然后只要您通常输入 conda 就使用 mambaconda activateconda deactivate 命令除外)。