Running remote script on remote interpreter in PyCharm - python

I have a python script on a remote server. I would like to run it on the remote server itself. However, PyCharm is not installed on the remote server and I need PyCharm to debug the code.
I have PyCharm on my local computer and I would like to run the script (which is on remote server) on the remote server using PyCharm on my local machine. I am aware of Deployment tools and remote server host in PyCharm. I do not know how to make them work together.
Having the script on my local computer is not really an option for me as there are huge data files involved with the code and I have very limited storage on my laptop.

I'm not sure if it's absolutely necessary to use Pycharm only for debugging on your remote server but if not, you can use pdb module for debugging too: https://docs.python.org/2/library/pdb.html

Related

Visual Studio Code Remote Python Debug on Windows

Is it possible to remotely develop and debug Python code on another PC on the same network (both Windows 10)? If so, what is the best way to do this?
I tried mapping a network drive to the project folder on the remote PC. I could open the folder in vs code, but cannot get it to start my virtual environment on the remote machine to start debugging. When I do "Select Python Interpreter" and choose the appropriate venv on the remote machine it does nothing. The same process works fine if the venv is installed on the development machine.
I normally use WSL remote for C++ development and it works great but cant find any documentation for remote Windows development, just WSL, docker and SSH (maybe an option?)
Advice appreciated. Thanks in advance...

Setting local PyCharm remote interpreter in docker container on remote server

I have:
local PyCharm
remote server with docker container
I want run in my local PyCharm code (code on remote server) in remote docker container Python interpreter, for debug.
How to set it up?
I also found articles on the Internet, with the following description that I did not need:
local PyCharm -> ssh server interpreter
local PyCharm -> local docker
While it's not impossible to connect pycharm debugger with your remote docker container, it's much easier to use terminal interactive debugger - pdb. There are a lot of pdb flavours, if you don't like plain console
webpdb graphical debugger in a browser
pudb ncurses version, has some extra features like always listing your location in code and local variables.
I highly recommend checking them out. I use pdb on daily basis to debug python code in local docker container that has a complex run script.

Pycharm IDE coding on remote server with ssh

I wonder if there is any way to coding python with remote server data and run the python script on remote server with pycharm only installed on my local machine?
The remote server can be access by two ip address (ssh and ftp each), id and password.
But when I try to use pycharm professional project interpreter, there always an error like this (the ip address I used is for ssh):
I know the easiest way is install jupyter notebbok on my remote server, but I don't have permission to do that.

How to remote debug in PyCharm

The issue I'm facing right now:
I deploy Python code on a remote host via SSH
the scripts are passed some arguments and must be ran by a specific user
the PyCharm run/debug configuration that I create connects through SSH via a different user (can't connect with the user that actually runs the scripts)
I want to remote debug this code via PyCharm...I managed to do all configuration, I just get permission errors.
Are there any ways on how I can run/debug the scripts as a specific user (like sudo su - user)?
I've read about specifying some Python Interpeter options in PyCharm's remote/debug configuration, but didn't manage to get a working solution.
If you want an easy and more flexible way to get into the PyCharm debugger, rather than necessarily having a one-click "play" button in PyCharm, you can use the debug server functionality. I've used this in situations where running some Python code isn't as simple as running python ....
See the Remote debug with a Python Debug Server docs for more details, but here's a rough summary of how it works:
Upload & install remote debugging helper egg on your server (On OSX, these are found under /Applications/PyCharm.app/Contents/debug-eggs)
Setup remote debug server run configuration: click on the drop-down run configuration menu, select Edit configurations..., hit the + button, choose Python remote debug.
The details entered here (somewhat confusingly) tell the remote server running the Python script how to connect to your laptop's PyCharm instance.
set Local host name to your laptop's IP address
set port to any free port that you can use on your laptop (e.g. 8888)
Now follow the remaining instructions in that dialog box: copy-paste the import and pydevd.settrace(...) statements into your code, specifically where you want your code to "hit a breakpoint". This is basically the PyCharm equivalent of import pdb; pdb.set_trace(). Make sure the changed code is sync'ed to your server.
Hit the bug button (next to play; this starts the PyCharm debug server), and run your Python script just like you'd normally do, under whatever user, environment etc. When the breakpoint is hit, PyCharm should drop into debug mode.
I have this (finally) working with ssh RemoteForward open, like so:
ssh -R 5678:localhost:5678 user#<remotehost>
Then start the script in this ssh session. The python script host must connect to localhost:5678 and of course your local pycharm debugger must listen to 5678
(or whatever port you choose)

run local python script from remote linux machine over ssh

I'm trying to run a python script on a remote linux machine accessed by ssh(putty). I want to change/access directory to the windows directory and run a program which converts files on the server to csv and saves them to the server.
Is it possible to run the program without moving the files from remote to local, run conversion, move local to remote?
I am not the root user and can't install anything on the linux machine.
My Windows is 64bit and the linux machine is 64bit Ubuntu. Any suggestions?
I found a way to do what I wanted. Doing what I initially wanted requires me to transfer the files from the local machine to the remote machine then running the script and transferring it back. Ultimately it's a function of how fast my internet connection is. Since my local connection isn't that strong, I realized that my initial thoughts were flawed. Eventually, I just uploaded my data to the remote machine and run the script there. It was the fastest solution

Categories