gfriends / gfriends-inputer

头像导入工具

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

源码运行报错

huihuidehui opened this issue · comments

使用git clone项目后在项目根目录下运行Gfriends Inputer.py报错:

FileNotFoundError                         Traceback (most recent call last)
File ~/code/gfriends-inputer/gfriends.py:772
    770     if work_path != config_path:
    771         from IPython import embed;embed()
--> 772         os.chdir(config_path)  # 切换工作目录
    773     logger.debug('修正运行目录:' + config_path + ':' + work_path)
    775 (config_file, quiet_flag, update_flag, debugflag) = argparse_function(version)

没仔细看代码,这块逻辑应该是要切换到项目根目录,可以尝试这样修改。

    # 类 Unix 系统的默认工作目录不在程序所在文件夹
    os.chdir(str(Path(__file_).parent))
    # config_path = '/'.join((sys.argv[0].replace('\\', '/')).split('/')[:-1])
    # work_path = os.getcwd().replace('\\', '/')
    # if work_path != config_path:
    #     os.chdir(config_path)  # 切换工作目录
    # logger.debug('修正运行目录:' + config_path + ':' + work_path)

在文件头部进行导入

from pathlib import Path

你是什么系统?什么 Python 版本?
这一段代码主要是适配 MacOS 的,因为 MacOS 双击图标(非终端执行)运行程序时,工作目录在 Users,而非文件所在路径。