VS Code remote debugging python (VS Code must be server) - python

I'm trying to use the VS Code remote debug feature (debugpy).
My problem is that my code to connect needs to be the client and VS Code needs to be the server.
Why? Because I can't modify the command line of my python "container" (It's an embedded version of python into another process). So I simply want to execute a command in my py code, which, then, connects to my debug server that has been startet in VS Code.
Is that possible? I know that this works in PyCharm professional, but I can't get it done in VS Code.
Thanks!

Related

Run local code on remote interpreter (VS CODE)

I have some code on my local machine which I want to run with the python interpreter or python present on the remote server.
Purpose of doing it: some part of my code contains some spark code which does not runs on my local machine but the spark code runs fine on remote machine. But the code is not present on the remote machine.
Please mention the solution related to VS CODE
Please help me.
I tried solving it by resolving spark issue but machine is not compatible. Checked few things on remote works fine. I am positive my code can work on remote interpreter. I know pycharm support it in professional version which I cant access. Please help me for VS CODE.
Please install Remote-SSH extension in extension store.
Then you can select Remote-SSH: Connect to Host... from the Command Palette ( Ctrl+Shift+P).
You could read document for more details about remote control.

Using shell_exec to run python script in a PHP file works when using localhost but not when put on the server

I am quite new to web development and have been trying to run some Python code via a PHP script. When working on my localhost, shell_exec works great. However, when putting it on the server (Hostinger), the Python script does not work.
I thought this might be the case because on the localhost it uses the Python installed on my computer, but I am not sure what is the best way around this.
Thank you!

Is there a way run a python script on another server?

I have a Djnago web application on IIS 6 on one server. Is there a way that from this website I call another python script that is on another server in such a way that that script just run itself there?
Calling or Runnig that script in the usual way as internet says, is not working.
I always get the error of os.getcwd() and it also doesn't allow to change that directory.
I just want to run that python script there on that server from this server.
Can anyone help?
Normally, I would recommend using a framework like fabric or winrm if you want to run a python script on another server. Those frameworks use ssh or windows remoting functionality, respectively, to allow a python program to execute other commands (including python scripts) on other systems. If the target machine is a windows machine, be forewarned that you can run into all sorts of UAC issues doing normal operations.

using flask in spyder stuck in local server

I am trying to create a web application using flask. I have already gotten somewhat comfortable with using python, and have done so using spyder, inside of Anacanda Navigator. Now I am playing around with flask doing basic functions and have successful so far by testing it out in local server 127.0.0.1:5000. The problem I am having is that I cannot stop the server once I run the script in spyder. I have stopped the script and run other scripts through the console, but the local server remains the same.
The reason this is a problem for me is because when I try to change files and run a different flask script, the server does not update with the new information. For example, if I run a flask script that returns "Hello World" on the main page, and then I stop that file, open a new file that has a different flask script that returns "The sky is blue" the server does not change when I check it on chrome or any other browser. It will onyl return "Hello World"
I have been able to fix this problem by completely restarting my computer, but I am wondering if there is another way, just to restart the local server, 127.0.0.1:5000. Thank You!
Also I am using windows
I do : "Run > Configuration per file > Execute in an external system terminal",
then when you run your .py containing the app.run, it will be launched in an external console. If you close the console the server will be closed too.
To Kill the local server, you may use Ctrl+C command and not any other command. This command is also mentioned when the server is up and running.
I've been having this precise issue and have been smashing my head against the wall for a couple of hours. I posted the referenced StackOverflow question (my first actually) and it seems that running a script from inside Spyder is the wrong way to go as it leaves runaway background processes running, even after restarting Spyder.
I got the recommendation to only launch my *.py code from the command prompt. Furthermore I was told to do this:
set FLASK_APP=main1.py then set FLASK_DEBUG=1 then flask run
though I'm not sure what that does, so I will investigate. I was about to restart my computer as a last ditch effort until I looked in my Windows Task Manager and found some Python tasks running. After [end task] them both I was able to launch the updated webpage on my local host.

debugging tornado server in docker container

I use PyDev with Eclipse as an IDE.
How can I debug a tornado server running inside a docker container using PyDev/Eclipse?
Is it possible to put breakpoints in PyDev/Eclipse and debug like a server running natively on my machine?
One option is using the remote debugger, so, you can add connect the running program to the Eclipse remote debugger (see http://www.pydev.org/manual_adv_remote_debugger.html). The only thing here is that it has to create a connection from the container to the host.
Another thing which could work (as in: I've never tested it) is creating an interpreter which always runs inside docker... an interpreter in PyDev can be any executable (such as a .sh), so, you can try making a script which will run python inside docker by default (although as I never tested this I can't say how well that'll work).

Categories