Closed Gavin1937 closed 5 months ago
这里我用的 PPOCR_api.py 是基于最新 main branch 里面的 https://github.com/hiroi-sora/PaddleOCR-json/blob/c19f3a2aa4bfb7bc7c08966465ec726c661e4f18/api/python/PPOCR_api.py
Traceback (most recent call last): File "/mnt/c/Users/user/Dev/PaddleOCR-json/api/python/demo1.py", line 14, in <module> ocr = GetOcrApi(r"../../cpp/build/ppocr", ipcMode='socket') File "/mnt/c/Users/user/Dev/PaddleOCR-json/api/python/PPOCR_api.py", line 223, in GetOcrApi return PPOCR_socket(exePath, argument) File "/mnt/c/Users/user/Dev/PaddleOCR-json/api/python/PPOCR_api.py", line 159, in __init__ super().__init__(exePath, argument) # 父类构造函数 File "/mnt/c/Users/user/Dev/PaddleOCR-json/api/python/PPOCR_api.py", line 37, in __init__ self.ret = subprocess.Popen( # 打开管道 File "/usr/lib/python3.10/subprocess.py", line 971, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '../../cpp/build/ppocr --port=0 --addr="loopback"'
python 官方是建议用 list 来表示输入进 subprocess.Popen() 的命令的。文档
subprocess.Popen()
command_line = input() /bin/vikings -input eggs.txt -output "spam spam.txt" -cmd "echo '$MONEY'" args = shlex.split(command_line) print(args) ['/bin/vikings', '-input', 'eggs.txt', '-output', 'spam spam.txt', '-cmd', "echo '$MONEY'"] p = subprocess.Popen(args) # Success!
不过不同系统的shell在处理这些命令的时候也会有不同的行为。这里在 linux 里面只需要把一整串命令给拆成list就可以修复这个bug了。
这里我用的 PPOCR_api.py 是基于最新 main branch 里面的 https://github.com/hiroi-sora/PaddleOCR-json/blob/c19f3a2aa4bfb7bc7c08966465ec726c661e4f18/api/python/PPOCR_api.py
python 官方是建议用 list 来表示输入进
subprocess.Popen()
的命令的。文档不过不同系统的shell在处理这些命令的时候也会有不同的行为。这里在 linux 里面只需要把一整串命令给拆成list就可以修复这个bug了。