我正在运行 OSX Sierra,并尝试运行 4 个模拟和一个模型图。它使用应该在 X11 窗口中返回图形结果的 Docker。
但是,我做了很多研究,发现以下建议对它们自己不起作用: - 检查 $DISPLAY 以确保其空白或清除 - 重新安装 XQuartz - 更改 XQuartz 安全设置以获取网络权限-修改 ifconfig
以下是当前输出:
INFO simconf 数据:time_sim=4 绘图=1
******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
For more information visit http://projects.coin-or.org/Ipopt
******************************************************************************
INFO Iteration 0 from 4
INFO Iteration 1 from 4
INFO Iteration 2 from 4
INFO Iteration 3 from 4
INFO Plotting
Traceback (most recent call last):
File "main.py", line 27, in <module>
main()
File "main.py", line 23, in main
simulator_1.simulate()
File "/app/src/algorithms/Envio-Algorithm-Tools/mpc_casadi/dmpc/../mpc_sim_tools_casadi/simulator_file.py", line 162, in simulate
mpc_sim_tools.plot(self.dmpc_sim_data.data_list[index_mpc], fig_settings)
File "/app/src/algorithms/Envio-Algorithm-Tools/mpc_casadi/dmpc/../mpc_sim_tools_casadi/mpc_sim_tools.py", line 8, in plot
fig = mpcplot(mpc_data.x.T, mpc_data.u.T, mpc_data.d.T, mpc_data.tplot, fig_dict=fig_settings)
File "/app/src/algorithms/Envio-Algorithm-Tools/mpc_casadi/dmpc/../mpc_sim_tools_casadi/mpc_sim_tools.py", line 43, in mpcplot
fig = plt.figure()
File "/usr/local/lib/python3.5/site-packages/matplotlib/pyplot.py", line 548, in figure
**kwargs)
File "/usr/local/lib/python3.5/site-packages/matplotlib/backend_bases.py", line 161, in new_figure_manager
return cls.new_figure_manager_given_figure(num, fig)
File "/usr/local/lib/python3.5/site-packages/matplotlib/backends/_backend_tk.py", line 1044, in new_figure_manager_given_figure
window = Tk.Tk(className="matplotlib")
File "/usr/local/lib/python3.5/tkinter/__init__.py", line 1876, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display "127.0.0.1:0.0"
The key issue appears to be in here:
_tkinter.TclError: couldn't connect to display "127.0.0.1:0.0"
以下是我之前运行的相关命令:
导出显示=127.0.0.1:0.0
docker create -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --name algorithm-tools-3 python-algorithm-tools-3
感谢所有帮助!