How to run/debug local code using remote interpreter in Pycharm? - python

I followed below instructions to setup remote interpreter and remote deployment.
https://medium.com/#erikhallstrm/work-remotely-with-pycharm-tensorflow-and-ssh-c60564be862d
It says the below
Deployment
The remote interpreter can not execute a local file, PyCharm have to
copy your source files (your project) to a destination folder on your
remote server, but this will be done automatically and you don’t need
to think about it!
However, I even after setting up automatic deployment in Tools|Deployment|Automatic Upload(always). It is not working as expected and not syncing up files between remote and local automatically in a seamless manner.
Question
So how can I just skip deployment and sync between remote and local folder all together and just run/debug my local code using remote interpreter?
I mean on a local .py file i should be able to but a breakpoint and debug using remote interpreter? This makes life more easier and not worry about sync.

Related

PyCharm remote debug using remote container Python interpreter

My situation is that I have set up a container in a remote server, and inside the container, there is a virtual environment. I'm using the python interpreter inside this virtual environment in this container, not the one on the host.
From my local machine, I can open up PyCharm, and use Tools->Deployment->Configuration to easily set up a remote connection. And For a specific project, I can set up the interpreter by clicking Files->Settings->Project Interpreter. However, it seems that I can only select the host Python interpreter(/usr/bin/python) on the remote server, not the one inside the virtual environment in the container. How could I set up using this interpreter?
I googled but can't find exact solution. I don't think I need to install Docker locally because my Docker is on the remote server side, right?
In similar way you are connecting to remote host - you would need to setup container with same capabilities e.g. set ssh server running on there. Then you should expose the port into public world or use nested ssh tunnel, which would be better alternative.
Another interesting approach (maybe recommended) is to forward Docker socket from the remote machine so, that you local Docker CLI uses this socket for sending commands to remote host. Theoretically, then you could add this container directly in PyCharm, when you set correct Docker host address there.
Further, virtual environments on other than local host systems are not supported natively by PyCharm. However, you could try to add path of python and see if it works e.g. venv/bin/python from project directory.

Cannot run project deployed on remote server through Pycharm

I deploy a project on a remote ssh server using Pycharm. I have mapped my local folder to the correct path in the remote server and the interpreter used is the one on the server.
When I run my project in Pycharm (deployment actually happens remotely) everything runs smoothly. But if I ssh into the machine and want to start running the project from within the machine, I get
ImportError: No module named 'replay_buffer'
and this applies exclusively to folders within the project (not library dependencies).
How do I fix this?

Run local batch file on remote system with Python WMI

I want to run a local batch file on a remote system with WMI, instead of running a batch file on the remote system. The reason behind this is that I'll need the directory to which I'm referencing in the batch file to be variable, and adjustable by the user. How exactly can I do this? Reference the local file and run it, or send it to the remote sytem? How do I code it either way?
The reason I chose WMI was because it has been extremely reliable thus far, and I have no intention of reusing PsExec, and I have no need for ssh.
Referencing the local file on the remote system is bad because the remote system user has to have access to the file system on your local system which is - viewed by the remote system - a remote system.
You would have to have a share on your local machine which is accessible from the remote system and modify the batch to access the UNC-Path (pushd).
The best way would be to copy the batch to the remote system (or create it dynamically on the remote system) and execute it from there.
How to create remote processes can be read at this question,
several ways to copy files to a remote system are described here

pycharm remote interpreter with two factor authentication

I would like to use PyCharm with a remote interpreter (in fact using the remote directory structure). The server I am connecting to has two factor authentication which requires a password and time changing code.
How do I setup a login so that PyCharm prompts me for the one time use code?
Will PyCharm use the remote directory structure as I would like or will it keep saving things locally?

IntelliJ IDEA - how to map remote PYTHONPATH to local environment?

I'm using python remote interpreter in IntelliJ(13.1), and using "composes" modules which are installed on server.
By importing the module like follwing, I can use the module without any problem, but I get warn "No module named composes".
import composes
And I can't get the auto complete of the module in editor.
Do I need to map the remote PYTHONPATH to local?
If so, please tell me how to do that.
I found some documentation for this:
http://www.jetbrains.com/pycharm/quickstart/configuring_interpreter.html
I think best way is remote SSH interpreter. Check this out.
Edit: But don't forget. If you choose remote interpreter, you can't use your local modules.
Edit2:
1) Add deployment server from Tool->Deployment->Configuration
2) Add remote interpreter from File->Settings->Project Interpreter->Add remote And select the Deployment Configuration for FTP connection and can send to server your local files
3) And now you can upload your files to server from Pycharm. For this Right click to project folder->Upload to xxx. If all configuration is okay, now your files will upload to server and you can use auto-completion for your local files.
If it doesn't work, please try File->Invalidate cache. And let it delete all cache and download over it again.

Categories

Resources