无法在MacOS上使用pip安装Flask

问题描述 投票:0回答:1

我正在尝试使用以下命令在我的 MacOS Ventura 上安装 Flask:

Pip3 install Flask

这给了我以下错误:

abdullah@MacBook-Pro ~ % pip3 install flask
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try brew install
    xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a Python library that isn't in Homebrew,
    use a virtual environment:
    
    python3 -m venv path/to/venv
    source path/to/venv/bin/activate
    python3 -m pip install xyz
    
    If you wish to install a Python application that isn't in Homebrew,
    it may be easiest to use 'pipx install xyz', which will manage a
    virtual environment for you. You can install pipx with
    
    brew install pipx
    
    You may restore the old behavior of pip by passing
    the '--break-system-packages' flag to pip, or by adding
    'break-system-packages = true' to your pip.conf file. The latter
    will permanently disable this error.
    
    If you disable this error, we STRONGLY recommend that you additionally
    pass the '--user' flag to pip, or set 'user = true' in your pip.conf
    file. Failure to do this can result in a broken Homebrew installation.
    
    Read more about this behavior here: <https://peps.python.org/pep-0668/>

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

当我按照说明并尝试使用 Homebrew 命令安装它时:

brew install flask

它会产生以下错误:

==> Downloading https://formulae.brew.sh/api/formula.jws.json
######################################################################### 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
######################################################################### 100.0%
Warning: No available formula with the name "flask". Did you mean flash, flank, flake or flac?
==> Searching for similarly named formulae and casks...
==> Formulae
flash               flank               flake               flac

To install flash, run:
  brew install flash
Haroon@MacBook-Pro ~ % poetry install flask

Poetry could not find a pyproject.toml file in /Users/Haroon or its parents

python macos flask homebrew
1个回答
0
投票

这对我有用:

  • 创建虚拟环境

python3 -m venv 环境名称

  • 激活环境

源环境名称/bin/activate

  • 使用 pip 安装 Flask

pip3 安装 Flask

  • 应该安装所有flask相关的包,然后检查是否安装正确

烧瓶--版本

© www.soinside.com 2019 - 2024. All rights reserved.