34

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.

enter image description here

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?

Błażej Michalik
  • 4,474
  • 40
  • 55
jim jarnac
  • 4,804
  • 11
  • 51
  • 88
  • It might be a configuration problem in Spyder of your remote server connection. What I understand of the screenshot is that your remote server try to reach a path of "Z:\notebook....etc" which obviously it is your local path....so i would say it is a problem of connection config in Spyder – jossefaz Apr 25 '20 at 17:43
  • 2
    I would check out these two links: https://medium.com/@halmubarak/connecting-spyder-ide-to-a-remote-ipython-kernel-25a322f2b2be https://medium.com/@mazzine.r/how-to-connect-your-spyder-ide-to-an-external-ipython-kernel-with-ssh-putty-tunnel-e1c679e44154 – gnahum May 11 '20 at 21:23
  • A couple of suggestions to try (I do not use Spyder): (1) It *looks as though* the quotation marks are not needed. Have you tried doing it as raw text? (2) I think Spyder wants the forward slash instead of the backslash for folder levels. I doubt either helps, but they are easy to try. – Mike Williamson Aug 06 '20 at 19:14
  • I had tried setting this up 2 years ago but gave up due to similar errors.. Now I work with PyCharm Pro, it has all this functionality and more.. The pro version is free if you have are a student.. – user2827262 Oct 02 '20 at 18:15
  • Yes or work on your local.. My conclusion :) – jim jarnac Oct 03 '20 at 11:32
  • just use ftp to down- and upload your files... – JanF Oct 18 '20 at 20:10

1 Answers1

1

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.

Cody Piersall
  • 8,312
  • 2
  • 43
  • 57