Debugging from pycharm (Ubuntu, macos)


I thought that it might be a good idea to run the game from pycharm. I didn’t have much time to look into everything, but I see two problems:

  • How would the run configuration look like if I can start the game with the currently developed bot? I assume that all necessary files are in the project, imports work, etc.

  • Is it possible at all if halite is a compiled executable, and locally you can run it only as a shell script?


I’m running PyCharm Pro on macOS, and was able to leverage remote debugging and a modified script:

Create a new “debug challenger” bot (I just copied to so that you have an opponent bot that won’t be trying to attach to the remote debugger.

Create a Python Remote Debug configuration per the docs at:

Create a new script:

./halite --no-timeout --replay-directory replays/ -vvv --width 32 --height 32 "python3" "python3"

The only changes from are disabling the timeout and changing one of the bots to

Sprinkle breakpoints in and start your remote debug session from PyCharm. Once it is listening for remote processes, execute ./ to launch the game. You should see the debugger in PyCharm stop at your breakpoint.

Good luck!


Thanks for this awesome guide, it saved me a lot of time:)

I’d like to add that one should probably specify a different port than 0 on the localhost to connect to the debugger, since 0 can be occupied by something else.


Thanks for this.

One thing that might be helpful for others. I noticed running required me to comment out the remote debug statements. Not a big deal, but I know I’ll forget that once or twice before submitting. Instead, I created a wrapper which calls See the debug section of for more details.


One thing I actually wound up doing was adding an optional command line argument to enable the remote debugging connection, and defaulting it to be disabled. Then I modified my debug script to launch two copies of my bot, but one with the command line arg enabling debugging.



thanks for the guide!
alas i’m having problems connecting:

G:\Dropbox\Python\HaliteV1>halite.exe --no-timeout --replay-directory replays/ -vvv --width 32 --height 32 “python” “python”
[info] Map seed is 1542134217
[info] [P0] Launching with command python
[info] [P1] Launching with command python
[info] [P0] Initializing player
[info] [P1] Initializing player
[info] [P0] Initialized player Could not connect to localhost
[info] [P1] Initialized player MyPythonBot
[info] Player initialization complete
[error] [1] [P0] Communication failed
[error] [1] [P0] Last input received was:
[error] [1] [P0] Traceback (most recent call last):
[error] [1] [P0] File “C:\Users\Jan\AppData\Local\Programs\Python\Python37\lib\site-packages_pydevd_bundle\”, line 549, in start_client
[error] [1] [P0] s.connect((host, port))
[error] [1] [P0] ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
[error] [1] [P0] Traceback (most recent call last):
[error] [1] [P0] File “”, line 3, in
[error] [1] [P0] pydevd.settrace(‘localhost’, port=2222, stdoutToServer=True, stderrToServer=True)
[error] [1] [P0] File “C:\Users\Jan\AppData\Local\Programs\Python\Python37\lib\site-packages\”, line 1314, in settrace
[error] [1] [P0] stop_at_frame,
[error] [1] [P0] File “C:\Users\Jan\AppData\Local\Programs\Python\Python37\lib\site-packages\”, line 1363, in _locked_settrace
[error] [1] [P0] debugger.connect(host, port) # Note: connect can raise error.
[error] [1] [P0] File “C:\Users\Jan\AppData\Local\Programs\Python\Python37\lib\site-packages\”, line 356, in connect
[error] [1] [P0] s = start_client(host, port)
[error] [1] [P0] File “C:\Users\Jan\AppData\Local\Programs\Python\Python37\lib\site-packages_pydevd_bundle\”, line 549, in start_client
[error] [1] [P0] s.connect((host, port))
[error] [1] [P0] ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
[warn] [1] [P0] Killing player

any idea?


Change port to 5000+ maybe? And ensure that remote debugger is configured to the same port.


same result :confused:
it connected when i set it to the debugger port here:

but when i hit the debugger button in pycharm it says


Hmm, maybe you are using something wrong?

import pydevd

pydevd.settrace('localhost', port=5678, stdoutToServer=True, stderrToServer=True)


what is this for? i followed @rpsoko 's guide:

still same problem


You change something in Settings -> Debug, while you need to create Remote Debuger in Configurations menu. (Remote debugging with the Python remote debug server configuration)
Edit: SO link


i did all that of course. this is all i changed:

is there nothing else you guys did? do i have to change windows settings maybe?

Live (turn by turn) bot debubbing and developement in Python (Windows)