Reputation: 5152
I am starting to use Spyder to edit code located on a remote server. I managed to connect to the kernel of my remote server. In order to be able to open and save (download, upload) the scripts, I installed Expandrive, that mapped the server as if it were an external hardrive on my machine. The server OS is Linux, my local one is Windows.
I thought that should work, but I am still receiving the error file not found
.
Any idea why?
On that other post: Spyder: How to edit a python script locally and execute it on a remote kernel?, it is suggested (second answer) to add some specific code to the %run
command file in order for the program to understand the dirpath syntax of linux.
# ----added to remap local dir to remote dir-------
localpath = "Z:\wk"
remotepath = "/mnt/sdb1/wk"
if localpath in filename:
# convert path to linux path
filename = filename.replace(localpath, remotepath)
filename = filename.replace("\\", "/")
# ----- END mod
Do you think that would adress my problem?
Upvotes: 34
Views: 4455
Reputation: 8557
The path for the %run
magic needs to be the path that the server sees, not the client. You are passing the path from the client's perspective.
When you type run Z:/blah/blah/blah.py
, your terminal sends that path to the IPython server to execute. The server looks for the path Z:/blah/blah/blah.py
, but since it doesn't exist on the server, the command fails with a file not found error.
The easiest solution is to just run the command with the path the server expects:
%run /path/to/blah/on/server/blah.py
Bottom line: remember that the server cannot access files that the client terminal is running on.
Upvotes: 1