ssh deployment and remote running: file not found

 

Hi there, I'm currently trying to setup PyCharm such that I can upload (from PyCharm) and run my code (inside PyCharm) on a remote server with bash (so like ssh://username@server:22).

The problem is that I can't run my code on the server in PyCharm, as I get the following error:

ssh://username@server:22/usr/bin/python -u /home/username/Programming/PythonCode/TestSetup.py bash: line 0: cd: /home/username/Programming/PythonCode: No such file or directory /usr/bin/python: can't open file '/home/username/Programming/PythonCode/TestSetup.py': [Errno 2] No such file or directory

So it looks like there's an easy configuration error in PyCharm but I just can't figure it out.

Some information on the folder structure and the PyCharm settings:

When you login on the server, the initial path is /home/username/. My code is stored and uploaded from deployment to /home/username/Programming/PythonCode, and python is available at /usr/bin/python.

Deployment options: Root path: /home/username , Local Path (on my local pc): /home/mmoser/PycharmProjects/General , Deployment path on server: /Programming/PythonCode. The upload of the code to my PythonCode works fine with these settings.

Run configuration: Script: /home/username/Programming/PythonCode/TestSetup.py (remote path), Working directory: /home/username/Programming/PythonCode (remote path).

So from my part, it looks like PyCharm can't execute the cd to change to the PythonCode folder, but I have no idea why because it works if I login manually via terminal and just copy the cd command.

Maybe somebody has an idea, thanks a lot already! :)

15 comments
Comment actions Permalink

I think I've run into the same problem. I could not use the Settings window to switch to remote development successfully. Instead, when I created a fresh new Python project, I changed the Python Interpreter settings to the remote interpreter BEFORE I clicked the Create button for the new project. That worked.

If I let the project first create pointing to my local directory, it seems that I cannot later change that so it keeps trying to use my local directory instead of the remote one. When I try to run, it does invoke ssh, but it supplies the wrong file path:

ssh://pi@192.168.1.41:22/usr/bin/python3 -u C:/Users/joe/PycharmProjects/RPi-Server/file2.py   (should be /home/pi/...)

1
Comment actions Permalink

Please check your path mappings in project interpreter settings. Try to delete the deployment and remote project interpreter, then re-create both with default settings and path mappings (it maps to /tmp/project-xxx directory on the remote host my default). 

0
Comment actions Permalink

I have the same problem. It's funny because with the exact same configuration (same project, same path mapping, deployment, executable, etc) some times works correctly and others not.

0
Comment actions Permalink

I've experienced the same bug in 4 versions of PyCharm now. The only way to work around it I found before was to delete and recreate the whole settings from 0.

Sadly that stopped working in 2020.3 and now nothing works — not even the default settings.

 

0
Comment actions Permalink

@235313

Please report it to https://youtrack.jetbrains.com/issues/PY and attach screenshots showing your SSH config and SSH interpreter in PyCharm along with idea.log file from Help | Show Log in...

0
Comment actions Permalink

I have kind of the same problem... but with CLion...

0
Comment actions Permalink

Hello, 

 

It looks like the following bug https://youtrack.jetbrains.com/issue/PY-47326 , please vote for it in order to be updated on the resolution. 

As a workaround, you can temporarily downgrade to 2020.2.5. 

 

I apologize for the inconvenience. 

0
Comment actions Permalink

Still happens on 2021.2.3 professional. Multiple times a week. This is impossible to work with

```

ssh://noam@ML:2203/miniconda/envs/py37/bin/python -u C:/Users/noam.s/src/algo_flows/algo_flows/inspection/segmentor_flow.py
sh: 1: cd: can't cd to C:/Users/noam.s/src/algo_flows/algo_flows/inspection
/miniconda/envs/py37/bin/python: can't open file 'C:/Users/noam.s/src/algo_flows/algo_flows/inspection/segmentor_flow.py': [Errno 2] No such file or directory

Process finished with exit code 2


```

 

0
Comment actions Permalink

Has there been any update on this? This is a major issue how has this not been resolved after 6(!) years?

0
Comment actions Permalink

Hello @Bot Frederiknolte

 

Are you running  PyCharm 2022.2.2?  If yes, please  report the problem to https://youtrack.jetbrains.com/issues/PY and attach screenshots showing your SSH config and SSH interpreter in PyCharm along with idea.log file from Help | Show Log in...

0

Please sign in to leave a comment.