15

在没有意识到这一点的情况下,我已经使用密码学包好几个月没有问题了,但是突然间它无法构建并且它使我的项目的开发停止了。

事实证明,密码学是我的 Pipfile 中其他包之一的依赖项:apns2. 正如我所说,它一直运行良好,但我的环境肯定发生了一些变化。这是我的 Pipfile,只隔离了那个包:

[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[requires]
python_version = "3.7.9"

[packages]

apns2 = "*"

[dev-packages]

这失败了。我使用pipenv(最新版本 2020.11.15),所以当我现在运行它时,输出如下:

# pipenv install
Creating a virtualenv for this project...
Pipfile: /Users/dylan/Dev/RideHare/server/Pipfile
Using /Users/dylan/.pyenv/versions/3.7.9/bin/python3.7m (3.7.9) to create virtualenv...
⠏ Creating virtual environment...created virtual environment CPython3.7.9.final.0-64 in 502ms
  creator CPython3Posix(dest=/Users/dylan/.local/share/virtualenvs/server-2uc2X-TS, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/dylan/Library/Application Support/virtualenv)
    added seed packages: pip==20.2.2, setuptools==51.0.0, wheel==0.35.1
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

✔ Successfully created virtual environment! 
Virtualenv location: /Users/dylan/.local/share/virtualenvs/server-2uc2X-TS
Installing dependencies from Pipfile.lock (aa4cd9)...
An error occurred while installing cryptography==3.3.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5' --hash=sha256:84ef7a0c10c24a7773163f917f1cb6b4444597efd505a8aed0a22e8c4780f27e --hash=sha256:788a3c9942df5e4371c199d10383f44a105d67d401fb4304178020142f020244 --hash=sha256:9f6b0492d111b43de5f70052e24c1f0951cb9e6022188ebcb1cc3a3d301469b0 --hash=sha256:a69bd3c68b98298f490e84519b954335154917eaab52cf582fa2c5c7efc6e812 --hash=sha256:b4890d5fb9b7a23e3bf8abf5a8a7da8e228f1e97dc96b30b95685df840b6914a --hash=sha256:0003a52a123602e1acee177dc90dd201f9bb1e73f24a070db7d36c588e8f5c7d --hash=sha256:7e177e4bea2de937a584b13645cab32f25e3d96fc0bc4a4cf99c27dc77682be6 --hash=sha256:dc42f645f8f3a489c3dd416730a514e7a91a59510ddaadc09d04224c098d3302 --hash=sha256:69e836c9e5ff4373ce6d3ab311c1a2eed274793083858d3cd4c7d12ce20d5f9c --hash=sha256:9e21301f7a1e7c03dbea73e8602905a4ebba641547a462b26dd03451e5769e7c --hash=sha256:0e85aaae861d0485eb5a79d33226dd6248d2a9f133b81532c8f5aae37de10ff7 --hash=sha256:c366df0401d1ec4e548bebe8f91d55ebcc0ec3137900d214dd7aac8427ef3030 --hash=sha256:594a1db4511bc4d960571536abe21b4e5c3003e8750ab8365fafce71c5d86901 --hash=sha256:83d9d2dfec70364a74f4e7c70ad04d3ca2e6a08b703606993407bf46b97868c5! Will try again.
     ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 10/10 — 00:00:08
Installing initially failed dependencies...
[InstallError]:   File "/usr/local/Cellar/pipenv/2020.11.15/libexec/lib/python3.9/site-packages/pipenv/cli/command.py", line 233, in install
[InstallError]:       retcode = do_install(
[InstallError]:   File "/usr/local/Cellar/pipenv/2020.11.15/libexec/lib/python3.9/site-packages/pipenv/core.py", line 2052, in do_install
[InstallError]:       do_init(
[InstallError]:   File "/usr/local/Cellar/pipenv/2020.11.15/libexec/lib/python3.9/site-packages/pipenv/core.py", line 1304, in do_init
[InstallError]:       do_install_dependencies(
[InstallError]:   File "/usr/local/Cellar/pipenv/2020.11.15/libexec/lib/python3.9/site-packages/pipenv/core.py", line 899, in do_install_dependencies
[InstallError]:       batch_install(
[InstallError]:   File "/usr/local/Cellar/pipenv/2020.11.15/libexec/lib/python3.9/site-packages/pipenv/core.py", line 796, in batch_install
[InstallError]:       _cleanup_procs(procs, failed_deps_queue, retry=retry)
[InstallError]:   File "/usr/local/Cellar/pipenv/2020.11.15/libexec/lib/python3.9/site-packages/pipenv/core.py", line 703, in _cleanup_procs
[InstallError]:       raise exceptions.InstallError(c.dep.name, extra=err_lines)
[pipenv.exceptions.InstallError]: Looking in indexes: https://pypi.python.org/simple
[pipenv.exceptions.InstallError]: Collecting cryptography==3.3.1
[pipenv.exceptions.InstallError]:   Using cached cryptography-3.3.1.tar.gz (539 kB)
[pipenv.exceptions.InstallError]: ERROR: Disabling PEP 517 processing is invalid: project specifies a build backend of setuptools.build_meta in pyproject.toml
ERROR: Couldn't install package: cryptography
 Package installation failed...
  ☤  ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/1 — 00:00:01

如果代替 Pipfile 中的 apns2 行,我明确地替换密码学(crytography =“*”),它也会以同样的方式失败。

4

5 回答 5

12

令人困惑的错误消息是由于 if/when由于某种原因pipenv无法构建cryptography,它会再次尝试--no-use-pep517(请参阅下面的评论),然后我们看到那些 PEP 517 禁用错误而不是根本原因!

要追踪您的实际问题,请尝试pip install cryptography(not pipenv),以便查看根本原因。

您可能需要安装rust和/或cargo,或openssl在您的平台上使用apt-get install,,或其他apk addbrew install然后再试一次。

以这种方式解决问题后,pipenv安装应该可以工作。

另请参阅cryptography包 github 问题 #5773

于 2021-02-09T23:34:15.777 回答
8

如果您使用的是最新的 macOS 版本,则 pipenv virtualenv 中的默认 pip 版本会错误地检测到您的操作系统版本,这会导致查找兼容的轮子失败(并且它将开始编译加密依赖项)。

为了避免它的根问题,您可以将 pip(在 virtualenv 中)升级到正确检测 mac os 的版本:

pipenv shell
pip install -U pip

该错误已在 pip 版本 20.3 (2020-11-30) https://github.com/pypa/pip/issues/9138中修复

于 2021-04-14T16:29:25.830 回答
7

似乎该cryptography软件包只能安装pip,而不是安装pipenv,所以先这样做......

brew install pkg-config libffi openssl
env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography

(取自这个问题的命令。)

...然后我可以运行pipenv installwhich 构建和安装一切正常。

于 2021-01-11T01:10:08.847 回答
1

不能使用 pipenv 安装的想法cryptography可以被揭穿:

编辑:我刚刚在https://pypi.org/project/cryptography/#history上看到v3.4.3 是几个小时前发布的。

 mkdir cryptography_test
❯ cd cryptography_test
❯ pipenv --version
pipenv, version 2020.11.15
❯ pip --version
pip 20.3.1 from /home/reinv/.local/lib/python3.8/site-packages/pip (python 3.8)
❯ pipenv install cryptography
Creating a virtualenv for this project...
Pipfile: /home/reinv/Documents/cryptography_test/Pipfile
Using /usr/bin/python3.8 (3.8.5) to create virtualenv...
⠼ Creating virtual environment...created virtual environment CPython3.8.5.final.0-64 in 246ms
  creator CPython3Posix(dest=/home/reinv/.local/share/virtualenvs/cryptography_test-tHdlLBeP, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/reinv/.local/share/virtualenv)
    added seed packages: pip==20.3.1, setuptools==51.1.2, wheel==0.36.2
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

✔ Successfully created virtual environment! 
Virtualenv location: /home/reinv/.local/share/virtualenvs/cryptography_test-tHdlLBeP
Creating a Pipfile for this project...
Installing cryptography...
Adding cryptography to Pipfile's [packages]...
✔ Installation Succeeded 
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success! 
Updated Pipfile.lock (8ed4d5)!
Installing dependencies from Pipfile.lock (8ed4d5)...
     ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
❯ pipenv shell
Launching subshell in virtual environment...
❯  . /home/reinv/.local/share/virtualenvs/cryptography_test-tHdlLBeP/bin/activate
❯ pip list
Package      Version
------------ -------
cffi         1.14.4
cryptography 3.4.3
pip          20.3.1
pycparser    2.20
setuptools   51.1.2
wheel        0.36.2

为什么这现在有效,我不知道,如果我在我的系统上转储一整套已安装的 ubuntu 软件包,我也无济于事。是的,cryptography突然开始ansible为我(作为子依赖项)破坏构建(这将我带到这里)。我也在使用 pipenv,但问题是为什么 pipenv 不能像@Dylan 建议的那样首先安装包,因为据我所知,pipenv 也使用 pip 作为包安装程序。

我不得不查找奇怪的“禁用 PEP 517 处理无效”消息是什么意思,但我认为这里有解释:https ://github.com/pypa/pipenv/issues/4481#issuecomment-706376607

简而言之:首先编译步骤失败,然后尝试使用--no-use-pep517包含在某处的选项的解决方法,该选项让您有点疯狂追逐。(我没有费心阅读整个PEP 517,因为它和我的双臂一样长,但我什至无法理解摘要。)

于 2021-02-09T16:26:36.723 回答
1

我有一个有点类似的问题(cffi而不是cryptography)。我升级了我的 pipenv 版本(特别是为我使用pip3 install --upgrade pipenv),它解决了这个问题。

于 2021-03-21T07:59:26.633 回答