Suppose the current buffer is editing a local file and you would like to evaluate some code on a Python inferior running in a remote machine. The following should work: (let ((default-directory "/ssh:some-remote-machine:/")) (run-python)) (python-shell-send-string "5+5") (python-shell-send-string "(5\n+5)") The first python-shell-send-string call indeed works. The second one produces an error, because a temporary file is created in the local machine instead of the remote one. The same kind of error happens if one tries to evaluate the region on the entire buffer. I've attached a small patch to fix this.