python-3.x - 在奥赛罗棋盘游戏中使用时,windows python 子进程将不起作用
问题描述
还在学习python,遇到了使用“AI”的棋盘游戏奥赛罗。[https://www.instructables.com/id/Othello-Artificial-Intelligence/][1] 游戏有两个版本 - 玩家对玩家和玩家对 AI。我遇到的问题是玩家与 AI,Othello_game.py。Othello_gui,播放器上的播放器可以正常工作。
错误是:
C:\Users\Joe\Documents\OthelloAI-master\OthelloAI-master> python othello_game.py [erika_5.py] [nathan_ai.py]
Traceback (most recent call last):
File "othello_game.py", line 157, in <module>
player1 = AiPlayerInterface(sys.argv[1],1)
File "othello_game.py", line 36, in __init__
self.process = subprocess.Popen(['python3',filename], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
init 编码为:
def __init__(self, filename, color):
self.color = color
self.process = subprocess.Popen(['python3',filename], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
name = self.process.stdout.readline().decode("ASCII").strip()
print("AI introduced itself as: {}".format(name))
self.name = name
self.process.stdin.write((str(color)+"\n").encode("ASCII"))
self.process.stdin.flush()
导入语句是:
import sys
import subprocess
from threading import Timer
from othello_shared import find_lines, get_possible_moves, play_move, get_score
任何帮助将不胜感激,只是学习子流程。[1]:https ://www.instructables.com/id/Othello-Artificial-Intelligence/
解决方案
感谢:How to use subprocess.Popen with built-in command on Windows (Dinesh Pundkar) 编辑只是一行:self.process = subprocess.Popen(['python',filename], shell=True, stdin=subprocess .PIPE,标准输出=子进程.PIPE)
推荐阅读
- java - 如何为rest api创建具有依赖项的jar
- java - 如果两者都在Java中的不同时区,如何将客户端日期值作为过滤器传递给服务器?
- windows-10 - 无法让 LAPACK 在 Windows 上运行
- python - 如何使用opencv2和python识别段落之间的空格并在它们之间画一条线
- c++-cli - C++/CLR 将静态库链接到动态库
- python - 如何在python中对两个np.array执行两个样本不等大小的t检验?
- python - 重新排列 csv rssi 数据以按时间和位置 Python 分组
- c# - CommandLineParser - 多次使用相同的开关/标志
- python - Spark DataFrame迭代添加列
- c# - 在 exe 托管的 WCF Web 服务中启用 HSTS