I am using a macbook pro 15 as local machine and I have a remote server running ubuntu 14.04
I want to use the remote intepreter to run all the computation but I want to write the code from my local machine.
When I try to run a simple file with pycharm I receive this error:
ssh://[email protected]:22/usr/bin/python3 -u /Users/donbeo/Documents/phd_code/prova.py
bash: line 0: cd: /Users/donbeo/Documents/phd_code: No such file or directory
/usr/bin/python3: can't open file '/Users/donbeo/Documents/phd_code/prova.py': [Errno 2] No such file or directory
Process finished with exit code 2
I saw few people reporting the same problem but I haven't found a good answer so far. Most of the questions are indeed referring to older versions of pycharm.
It is clear that the file is not in my remote machine because I create it with pycharm in my local one. I was expecting pycharm to do some sort of synchronisation between the local and remote machine.
To execute your code on remote machine you'll have to perform few steps
Python Version (ssh://login@host:port/path/to/interpreter)
. Package list should be populated with records./
is equivalent to /my/root/path
, /dir
to /my/root/path/dir
etc.Be sure your interpreter is chosen as SSH which is to compile, not STFP which is for deployment.
Sometimes you can have everything set up correctly (interpreter, deployment, Path mapping, etc) but PyCharm keeps trying to use your local path on the remote machine.
If this happens, try this 4 fixes:
File->Invalid Caches / Restart
...if the problem is still not fixed:
Preferences->Python Interpreter->Path Mappings
and check the path mappings of the interpreter. They should look more or less like this:...again, if the previous step didn't work:
Run->Edit Configurations...
and check if the path mappings are correct:ModuleNotFoundError
but the connection seems to work, go to Run->Edit Configurations...->Environment Variables
and add your project's root path to the PYTHONPATH
variable.I'm running PyCharm 2018.3
First, I didn't have the [Errno 2] No such file or directory
problem. Then I had the problem out of nowhere.
The issue arose when I did:
By doing the steps above, I had [Errno 2] No such file or directory
problem.
The reason is that the folder is not automatically synced to the remote server (a bug?), nor could I find a way to configure it to sync. Configuring Deployment
and Path Mappings
did work, but it's too much manual labor and prone to error.
All I had to do is to add a new remote interpreter, despite that identical configurations already exists previously. (To be safe, I did remove the old ssh interpreter and the old deployments, also removed .idea folder) Then everything worked as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With