You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac Catalina安装bench报错:无匹配的RestrictedPython~=6.0版本

解决Bench初始化时RestrictedPython版本不兼容问题

问题背景

在Mac OS Catalina系统执行bench init frappe-bench时失败,核心原因是当前使用的Python版本为3.12.0b1,而Frappe依赖的RestrictedPython~=6.0要求Python版本<3.12,导致pip无法找到匹配版本,最终触发回滚操作。

完整报错信息:

(base) sarthakkatiyar@sanjay-mishra-3 ~ % cd ~                     
bench init frappe-bench
Setting Up Environment
$ python3 -m venv env
$ /Users/sarthakkatiyar/frappe-bench/env/bin/python -m pip install --quiet --upgrade pip
$ /Users/sarthakkatiyar/frappe-bench/env/bin/python -m pip install --quiet wheel
Getting frappe
$ git clone https://github.com/frappe/frappe.git  --depth 1 --origin upstream
Cloning into 'frappe'...
remote: Enumerating objects: 3213, done.
remote: Counting objects: 100% (3213/3213), done.
remote: Compressing objects: 100% (2848/2848), done.
remote: Total 3213 (delta 402), reused 1989 (delta 267), pack-reused 0
Receiving objects: 100% (3213/3213), 17.15 MiB | 4.14 MiB/s, done.
Resolving deltas: 100% (402/402), done.
Installing frappe
$ /Users/sarthakkatiyar/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /Users/sarthakkatiyar/frappe-bench/apps/frappe 
ERROR: Ignored the following versions that require a different python version: 5.1 Requires-Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.10; 5.2 Requires-Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.11; 5.2a1.dev0 Requires-Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.11; 5.3a1.dev0 Requires-Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.12; 6.0 Requires-Python >=3.6, <3.12; 6.0a1.dev0 Requires-Python >=3.6, <3.12
ERROR: Could not find a version that satisfies the requirement RestrictedPython~=6.0 (from frappe) (from versions: 3.4.2, 3.4.3, 3.5.0, 3.5.1, 3.5.2, 3.6.0a1, 3.6.0, 4.0a1, 4.0a2, 4.0a3, 4.0b1, 4.0b2, 4.0b3, 4.0b4, 4.0b5, 4.0b6, 4.0b7, 4.0b8, 4.0, 5.0, 7.0a1.dev0)
ERROR: No matching distribution found for RestrictedPython~=6.0
subprocess.CalledProcessError: Command '/Users/sarthakkatiyar/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /Users/sarthakkatiyar/frappe-bench/apps/frappe ' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/anaconda3/lib/python3.9/site-packages/bench/commands/make.py", line 68, in init
    init(
  File "/opt/anaconda3/lib/python3.9/site-packages/bench/utils/render.py", line 105, in wrapper_fn
    return fn(*args, **kwargs)
  File "/opt/anaconda3/lib/python3.9/site-packages/bench/utils/system.py", line 79, in init
    get_app(
  File "/opt/anaconda3/lib/python3.9/site-packages/bench/app.py", line 444, in get_app
    app.install(verbose=verbose, skip_assets=skip_assets, restart_bench=restart_bench)
  File "/opt/anaconda3/lib/python3.9/site-packages/bench/utils/render.py", line 126, in wrapper_fn
    return fn(*args, **kwargs)
  File "/opt/anaconda3/lib/python3.9/site-packages/bench/app.py", line 242, in install
    install_app(
  File "/opt/anaconda3/lib/python3.9/site-packages/bench/app.py", line 573, in install_app
    bench.run(
  File "/opt/anaconda3/lib/python3.9/site-packages/bench/bench.py", line 48, in run
    return exec_cmd(cmd, cwd=cwd or self.cwd, _raise=_raise)
  File "/opt/anaconda3/lib/python3.9/site-packages/bench/utils/__init__.py", line 158, in exec_cmd
    raise CommandFailedError from subprocess.CalledProcessError(return_code, cmd)
bench.exceptions.CommandFailedError

ERROR: There was a problem while creating frappe-bench
Do you want to rollback these changes? [y/N]: y
INFO: Rolling back Bench "frappe-bench"
(base) sarthakkatiyar@sanjay-mishra-3 ~ % python --version
Python 3.12.0b1

解决方案

方法一:使用pyenv管理Python版本(推荐)

  • 安装pyenv:
    brew install pyenv
    
    若未安装Homebrew,可通过官方脚本完成安装。
  • 安装兼容的Python版本(以3.11.6为例):
    pyenv install 3.11.6
    
  • 在当前目录设置使用该版本:
    pyenv local 3.11.6
    
    执行python --version验证,应显示Python 3.11.6
  • 重新执行Bench初始化:
    bench init frappe-bench
    

方法二:使用conda创建指定Python版本的环境

  • 创建Python 3.11的虚拟环境:
    conda create -n frappe-env python=3.11
    
  • 激活环境:
    conda activate frappe-env
    
  • 执行Bench初始化:
    bench init frappe-bench
    

内容的提问来源于stack exchange,提问作者Sarthak Katiyar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 16:07:03