Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Risk plot_board() not plotting after I enable X11 window forwarding #533

Closed
adamzterenyi opened this issue Apr 23, 2023 · 1 comment
Closed

Comments

@adamzterenyi
Copy link
Contributor

Hey Mike, I'm having an issue with the plot_board() function. I have followed the instructions in your video and logged in with -x to enable X11 forwarding; despite this, I am still running into an issue with the $DISPLAY variable. I even tried to use -y to no desired effect.

Here is my code:

from risk.board import Board,Territory
import copy

# define boards for the tests
# HINT: I recommend you plot these boards
board0 = Board([Territory(territory_id=i, player_id=1, armies=i%5+1) for i in range(42)])

board1 = copy.deepcopy(board0)
board1.set_owner(3,0)
board1.set_armies(3,500)
board1.set_armies(4,500)
board1.set_armies(34,500)
board1.set_armies(39,500)
board1.set_armies(35,500)

board2 = copy.deepcopy(board1)
board2.set_owner(34, 0)
board2.set_armies(34,1)
board2.set_owner(35, 0)
board2.set_armies(35,1)
board2.set_owner(39, 0)
board2.set_armies(39,1)

board3 = copy.deepcopy(board2)
board3.set_owner(34, 1)

board4 = copy.deepcopy(board2)
board4.set_owner(4, 0)
board4.set_armies(4, 1)
board4.set_owner(1, 0)

board5 = Board([Territory(territory_id=i, player_id=i%5, armies=i%5+1) for i in range(42)])

Like pulsar-heart in Issue #525, when I run this file, I receive a similar error code:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/Adam.Terenyi.25/risk/risk/board.py", line 410, in plot_board
    fig, ax = plt.subplots(figsize=(img_width/dpi, 300/dpi), dpi=dpi)
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 1176, in subplots
    fig = figure(**fig_kw)
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 539, in figure
    **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/backend_bases.py", line 171, in new_figure_manager
    return cls.new_figure_manager_given_figure(num, fig)
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 1049, in new_figure_manager_given_figure
    window = Tk.Tk(className="matplotlib")
  File "/usr/lib/python3.6/tkinter/__init__.py", line 2023, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

I have no idea what to do, as I have tried to fix this using online tutorials and have followed your instructions.

Thank you.

@mikeizbicki
Copy link
Owner

I believe this was resolved in office hours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants