authorize_python_access.sh 617 B

1234567891011121314151617181920
  1. #!/bin/bash
  2. # 获取 conda 环境中的 Python 可执行文件路径
  3. PYTHON_BIN=$(which python3)
  4. echo "🔍 当前 Python 路径: $PYTHON_BIN"
  5. # 拷贝路径到剪贴板
  6. echo "$PYTHON_BIN" | pbcopy
  7. echo "✅ 路径已复制到剪贴板"
  8. # 打开辅助功能设置界面
  9. open "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"
  10. # 弹出提示
  11. osascript <<EOF
  12. tell application "System Events"
  13. display dialog "请手动将以下 Python 路径添加到『辅助功能』中:\n\n$PYTHON_BIN\n\n路径已复制到剪贴板。" buttons {"知道了"} default button "知道了"
  14. end tell
  15. EOF