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! :)

3
20 comments

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

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

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

@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

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

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

0

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

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

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

1

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

The problem has been there for so many many years. Even re-adding the remote interpreter several times doesn't work, it's still mapped to a /tmp folder. It happens for every time when I set up a new project. 

And also this problem: https://stackoverflow.com/questions/54942881/pycharm-cant-get-remote-credentials-for-deployment-server

PyCharm 2022.2.4 (Professional Edition)
Build #PY-222.4459.20, built on November 17, 2022
macOS 13.2.1

1

When I had the problem, I believe it had to do with path variables from my local machine being copied to the server during execution. This can be disabled in the Run Configuration. In the field in which to enter the Environment Variables there is a small button on the right side. If you click it a window opens. There, deactivate "Include system environment variables". This setting sometimes gets turned on automatically for whatever reason so it might be that you have to unselect it every now and then.

1

I paid for professional specifically for this remote development option, I want be able to develop my code locally but deploy the code and interpret this on a remote Linux system. Seems to me  this would be a common development scenario.
The remote interpreter settings look OK but all the options to DEPLOY are greyed out or just does not seem to do the deployment at all. 

/home/pi/bin/python /tmp/Qp6Vv6Cm2m/main.py 
/home/pi/bin/python: can't open file '/tmp/Qp6Vv6Cm2m/main.py': [Errno 2] No such file or directory

Process finished with exit code 2


Currently very disappointed with this product. 

2
Please create an issue on YouTrack regarding this problem, or contact us directly with Help | Contact Support.
1

Oh it has been an issue for a while (see PY-55207 Restore editing *legacy* SSH-based Python interpreters). It just seems like PyCharm is bleeding features that existed in previous versions and it is not getting fixed because effort is focussed on new features.

2

Please sign in to leave a comment.