mirror of
https://github.com/LibraHp/GetQzonehistory.git
synced 2024-12-27 06:29:55 +00:00
修复macOS上运行报错
更新依赖,解决报错 支持macOS自动安装zbar依赖 在Linux上实现pause命令效果
This commit is contained in:
parent
dae30ecce8
commit
f2dcc987ff
5
main.py
5
main.py
@ -190,7 +190,10 @@ def save_data():
|
||||
current_directory = os.getcwd()
|
||||
# os.startfile(current_directory + user_save_path[1:])
|
||||
open_file(current_directory + user_save_path[1:])
|
||||
os.system('pause')
|
||||
if platform.system() == 'Windows':
|
||||
os.system('pause')
|
||||
else:
|
||||
os.system('stty raw -echo;dd bs=1 count=1 >/dev/null 2>&1;stty cooked echo')
|
||||
|
||||
|
||||
# 打开文件展示
|
||||
|
@ -1,10 +1,10 @@
|
||||
beautifulsoup4==4.12.3
|
||||
pandas==2.2.0
|
||||
tqdm==4.66.2
|
||||
requests==2.31.0
|
||||
Pillow==10.2.0
|
||||
pyarrow==14.0.1
|
||||
openpyxl==3.1.2
|
||||
pandas==2.2.3
|
||||
tqdm==4.67.0
|
||||
requests==2.32.3
|
||||
Pillow==11.0.0
|
||||
pyarrow==18.0.0
|
||||
openpyxl==3.1.5
|
||||
pyzbar~=0.1.9
|
||||
qrcode~=7.4.2
|
||||
qrcode~=8.0
|
||||
fake-useragent
|
@ -1,5 +1,7 @@
|
||||
import platform
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import qrcode
|
||||
import requests
|
||||
@ -9,15 +11,45 @@ try:
|
||||
from pyzbar.pyzbar import decode
|
||||
except Exception as e:
|
||||
print("无法找到 zbar 共享库。请确保安装了 zbar。")
|
||||
import_success = False
|
||||
|
||||
if platform.system() == "Linux":
|
||||
print("对于基于 RPM 的系统(如 Fedora), 您可以运行以下命令:")
|
||||
print("sudo dnf install -y zbar")
|
||||
elif platform.system() == "Darwin":
|
||||
print("MacOS 安装 zbar 请参考:")
|
||||
print("https://github.com/LibraHp/GetQzonehistory/issues/23#issuecomment-2349269027")
|
||||
|
||||
try:
|
||||
subprocess.check_call(["brew", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
print("检测到您已安装 Homebrew。是否通过 Homebrew 安装 zbar? (y/n)")
|
||||
user_input = input().strip().lower()
|
||||
|
||||
if user_input == "y":
|
||||
# 安装 zbar
|
||||
subprocess.check_call(["brew", "install", "zbar"])
|
||||
|
||||
# 创建 lib 目录和符号链接
|
||||
if not os.path.exists("lib"):
|
||||
os.makedirs("lib")
|
||||
|
||||
zbar_lib_path = os.path.join(subprocess.check_output(["brew", "--prefix", "zbar"], text=True).strip(), "lib", "libzbar.dylib")
|
||||
subprocess.check_call(["ln", "-s", zbar_lib_path, "./lib/libzbar.dylib"])
|
||||
print("zbar 安装并配置成功。")
|
||||
|
||||
# 尝试导入 pyzbar
|
||||
from pyzbar.pyzbar import decode
|
||||
import_success = True
|
||||
except FileNotFoundError:
|
||||
print("未检测到 Homebrew。请先安装 Homebrew 或参考文档手动安装 zbar。")
|
||||
except subprocess.CalledProcessError:
|
||||
print("检测 Homebrew 版本时出错,请确保 Homebrew 正常安装。")
|
||||
except Exception as install_error:
|
||||
print(f"安装过程中发生错误: {install_error}")
|
||||
|
||||
if not import_success:
|
||||
print("有关更多安装指南,请参考 zbar 的官方文档或您的发行版文档。")
|
||||
sys.exit(1)
|
||||
print("有关更多安装指南,请参考 zbar 的官方文档或您的发行版文档。")
|
||||
sys.exit(1)
|
||||
|
||||
import time
|
||||
import re
|
||||
|
Loading…
Reference in New Issue
Block a user