IrisRainbowNeko / genshin_auto_fish

基于深度强化学习的原神自动钓鱼AI
4.77k stars 719 forks source link

BUG FIXed! #171

Closed Tsuki0125 closed 2 years ago

Tsuki0125 commented 2 years ago

新合并的版本中,wasabiegg大佬引入了一些bug,导致在运行requirement.py时会出现至少三处报错。 通过修改requirement.py部分代码可以成功运行。修改后的代码以及运行command和结果如下:

image

image

# import pip
import subprocess
import sys
import argparse

# use python type hints to make code more readable
from typing import List, Optional

def pip_install(proxy: Optional[str], args: List[str]) -> None:
    if proxy is None:
        # pip.main(["install", f"--proxy={proxy}", *args])
        subprocess.run(
            [sys.executable, "-m", "pip", "install", *args],
            # capture_output=False,
            check=True,
        )
    else:
        subprocess.run(
            [sys.executable, "-m", "pip", "install", f"--proxy={proxy}", *args],
            # capture_output=False,
            check=True,
        )

def main():
    parser = argparse.ArgumentParser(description="install requirements")
    parser.add_argument("--cuda", default=None, type=str)
    parser.add_argument(
        "--proxy",
        default=None,
        type=str,
        help="specify http proxy, [http://127.0.0.1:7890]",#这里填你的本地代理服务器ip以及端口号,你的设置可能和我不一样
    )
    args = parser.parse_args()

    pkgs = f"""
    cython
    scikit-image
    loguru
    matplotlib
    tabulate
    tqdm
    pywin32
    PyAutoGUI
    PyYAML>=5.3.1
    opencv_python
    keyboard
    Pillow
    pymouse
    numpy==1.19.5
    torch==1.7.0+{"cpu" if args.cuda is None else "cu" + args.cuda} -f https://download.pytorch.org/whl/torch_stable.html
    torchvision==0.8.1+{"cpu" if args.cuda is None else "cu" + args.cuda} --no-deps -f https://download.pytorch.org/whl/torch_stable.html
    thop --no-deps
    git+git://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
    """

    for line in pkgs.split("\n"):
        # handle multiple space in an empty line
        line = line.strip()

        if len(line) > 0:
            # use pip's internal APIs in this way is deprecated. This will fail in a future version of pip.
            # The most reliable approach, and the one that is fully supported, is to run pip in a subprocess.
            # ref: https://pip.pypa.io/en/latest/user_guide/#using-pip-from-your-program
            # pip.main(['install', *line.split()])

            pip_install(args.proxy, line.split())

    print("\nsuccessfully installed requirements!")

if __name__ == "__main__":
    main()
Tsuki0125 commented 2 years ago

注意上图中,调用的proxy代理服务器ip是你自己电脑的网络代理配置。。。注意不要照抄