错误:无法为使用PEP 517的bcrypt构建轮,因此无法直接安装

23

由于某些原因,Pycharm中的解释器配置变得无效,因此我为正在进行的项目创建了一个新的虚拟环境,并重新安装了依赖项。但是我在重新安装bcrypt时遇到了问题。以下是完整的错误信息。该项目在之前的解释器上运行良好,因此我怀疑Python版本与此有关。我尝试安装wheel,因为错误提示说“无法构建wheel”,但这也没有起作用。

Collecting flask-bcrypt
      Using cached https://files.pythonhosted.org/packages/1d/c0/6d4c04d007d72b355de24e7a223978d1a95732245f
    9e9becbf45d3024bf8/Flask-Bcrypt-0.7.1.tar.gz
    Requirement already satisfied: Flask in c:\users\User\appdata\local\programs\python\python38-3
    2\lib\site-packages (from flask-bcrypt) (1.1.2)
    Collecting bcrypt (from flask-bcrypt)
      Using cached https://files.pythonhosted.org/packages/d8/ba/21c475ead997ee21502d30f76fd93ad8d5858d19a3
    fad7cd153de698c4dd/bcrypt-3.2.0.tar.gz
      Installing build dependencies ... done
      Getting requirements to build wheel ... done
        Preparing wheel metadata ... done
    Requirement already satisfied: Jinja2>=2.10.1 in c:\users\User\appdata\local\programs\python\p
    ython38-32\lib\site-packages (from Flask->flask-bcrypt) (2.11.2)
    Requirement already satisfied: Werkzeug>=0.15 in c:\users\User\appdata\local\programs\python\p
    ython38-32\lib\site-packages (from Flask->flask-bcrypt) (1.0.1)
    Requirement already satisfied: itsdangerous>=0.24 in c:\users\User\appdata\local\programs\pyth
    on\python38-32\lib\site-packages (from Flask->flask-bcrypt) (1.1.0)
    Requirement already satisfied: click>=5.1 in c:\users\User\appdata\local\programs\python\pytho
    n38-32\lib\site-packages (from Flask->flask-bcrypt) (7.1.2)
    Requirement already satisfied: six>=1.4.1 in c:\users\User\appdata\roaming\python\python38\sit
    e-packages (from bcrypt->flask-bcrypt) (1.15.0)
    Requirement already satisfied: cffi>=1.1 in c:\users\User\appdata\local\programs\python\python
    38-32\lib\site-packages (from bcrypt->flask-bcrypt) (1.14.2)
    Requirement already satisfied: MarkupSafe>=0.23 in c:\users\User\appdata\local\programs\python
    \python38-32\lib\site-packages (from Jinja2>=2.10.1->Flask->flask-bcrypt) (1.1.1)
    Requirement already satisfied: pycparser in c:\users\User\appdata\local\programs\python\python
    38-32\lib\site-packages (from cffi>=1.1->bcrypt->flask-bcrypt) (2.20)
    Building wheels for collected packages: bcrypt
      Building wheel for bcrypt (PEP 517) ... error
      ERROR: Command errored out with exit status 1:
       command: 'c:\users\User\appdata\local\programs\python\python38-32\python.exe' 'c:\users\User\appdata\local\programs\python\python38-32\lib\site-packages\pip\_vendor\pep517\_in_process.p
    y' build_wheel 'C:\conda_temp\tmpgl0zt2ul'
           cwd: C:\conda_temp\pip-install-9i9ne9yb\bcrypt
      Complete output (15 lines):
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win32-3.8
      creating build\lib.win32-3.8\bcrypt
      copying src\bcrypt\__about__.py -> build\lib.win32-3.8\bcrypt
      copying src\bcrypt\__init__.py -> build\lib.win32-3.8\bcrypt
      copying src\bcrypt\py.typed -> build\lib.win32-3.8\bcrypt
      running build_ext
      generating cffi module 'build\\temp.win32-3.8\\Release\\_bcrypt.c'
      creating build\temp.win32-3.8
      creating build\temp.win32-3.8\Release
      building '_bcrypt' extension
      error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://vi
    sualstudio.microsoft.com/downloads/
      ----------------------------------------
      ERROR: Failed building wheel for bcrypt
      Running setup.py clean for bcrypt
    Failed to build bcrypt
    ERROR: Could not build wheels for bcrypt which use PEP 517 and cannot be installed directly
    WARNING: You are using pip version 19.2.3, however version 20.2.2 is available.
    You should consider upgrading via the 'python -m pip install --upgrade pip' command.

1
错误非常明显:错误:需要 Microsoft Visual C++ 14.0。请使用“Visual Studio Build Tools”获取它:https://visualstudio.microsoft.com/downloads/ - C.Nivs
1
这个回答解决了你的问题吗?Pip错误:需要Microsoft Visual C++ 14.0 - C.Nivs
@C.Nivs 我也有Visual Studio,但我正在使用Pycharm工作。 - stumbling_errors
没错,这个链接安装了C++的构建工具,不需要VS。 - C.Nivs
@C.Nivs,您能告诉我需要从该链接安装什么吗? - stumbling_errors
显示剩余4条评论
8个回答

28

尝试使用这些命令:

python -m pip install --upgrade pip
python -m pip install --no-use-pep517 bcrypt

1
python -m pip install --upgrade pip - Piyush Balapure
7
“--no-use-pep517” 是个明智的建议,使用这个选项安装“bcrypt”毫不费力。 - sanyassh
起初它没有解决我的问题。然后我使用brew安装了这些库,然后使用了你的答案,问题得到了解决。https://dev59.com/zFQK5IYBdhLWcg3wefv_#56700040 - Cagatay Barin
我正在使用 Visual Studio Code IDE 工作,仅仅运行这个命令 python -m pip install --upgrade pip 就解决了我的代码问题。之后我只需要通过 pip install bcrypt 重新安装 bcrypt 就解决了! - Corina Roca
这个解决方案已经安装了bcrypt,但是其他要求,如bsdiff4和numpy,都失败了,尽管所有的Microsoft Visual C++版本都已经安装。 - Konstantinos

3

bcrypt 现在使用 Rust 实现。从源代码构建的用户需要有 Rust 编译器可用,但是对于下载预编译包的用户没有任何变化。

bcrypt 开发人员不再提供 manylinux2010 预编译包。用户应升级到最新版本的 pip ,以确保在其平台上下载预编译包时不会出现问题或使用旧版本低于 4.0.0

因此,请尝试:

pip3 install -U "bcrypt<4.0.0"

实际上,在我的情况下安装4.0.0版本有所帮助 :) - Wojtek_B
这个解决方案适用于我的Python 3.6pip 21.2。我尝试从源代码安装bcrypt 4.1,但失败了。降级到较低版本的bcrypt 3.6就可以了! - user3503711

2

我做的可能也适用于你:

$ python -m pip install --upgrade pip
$ python -m pip install --no-use-pep517 bcrypt

而且它起作用了。

2

bcrypt修复到3.2.2(在4.0.0之前的最新版本)对我解决了这个问题。就像这里所述的一样:这里

问题出现在bcrypt 4.0.0上,因为没有可用的wheel。


0

将Python从32位版本更改为64位版本可能是解决方案。这对我有所帮助。


0
我通过升级pip版本成功解决了这个问题: python -m pip install --upgrade pip 之后,我成功安装了flask-bcrypt包: pip install flask-bcrypt

-1

尝试

pip install pep517

PIP非常不可靠,它需要在Python下安装超过350个不同的软件包,并且还会影响整个系统。


-1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接