Restarting and debugging python application in virtual machine - python

I use Windows host and Ubuntu guest with VirtualBox. Flask application sources are shared from host to guest using VirtualBox shared folders and my virtualenvs and nginx are on guest.
Now I should open SSH session to restart my Flask application (debugging with reload enabled, but in case of syntax error it needs a rerun) and I have no debug capabilities.
I used to use PyDev and Windows installation of Python with debug and restart right from IDE and miss this.

For debugging you can use the remote debugger: http://pydev.org/manual_adv_remote_debugger.html (just point it to your main box IP and things should work).
Now, currently PyDev does not support launching a process through ssh, so, that'd be a new feature request (which you can request at: https://sw-brainwy.rhcloud.com/tracker/PyDev).

Related

How to connect local PyCharm to python installed on a server? Is this even possible?

I have PyCharm on my machine (8GB RAM). I am required to to heavy data processing, and would like to use an institutionally provided server. This server has Python installed, but without any IDE. So all I see is a CUI, and it is difficult to program in such an environment.Also note that I cannot ask server admin to install software on the server for me. So, how can one connect one's local PyCharm to a python installed on a remote server? Is this even possible?
You can configure an interpreter using SSH:
Open the Add Python Interpreter dialogue
In the left-hand pane of the Add Python Interpreter dialogue, click SSH Interpreter.
Follow the wizard.
For more detailed instructions, check:
https://www.jetbrains.com/help/pycharm/configuring-remote-interpreters-via-ssh.html
Note: unfortunately, this option is not available in the PyCharm Community Edition.

How do I debug a python container in intellij?

The docker plugin has a debug port for connecting to a container
I have a python application, but according to the docs the debug port is only supported for java.
How can I set breakpoints and debug my python container in intellij? Is there some way I could have the python container connect to the intellij python debugger?
Edit: I'm running Windows 10, docker for Windows, and the container is linux. Perhaps I need to manually setup some kind of remote debugging for the intellij Python debugger? Also, might as well ask, must I have the professional version for remote debugging or is there a workaround using community?
You can do that using Python Remote Debugging. Open the configurations window and click on + -> Python Remote Debug
Then you either set a port or keep it blank for Pycharm to find a available port.
Then click on Debug icon to launch the debug server which will show below kind of message
Starting debug server at port 57588
Use the following code to connect to the debugger:
import pydevd
pydevd.settrace('localhost', port=57588, stdoutToServer=True, stderrToServer=True)
Waiting for process connection...
Now you need to setup pydev debugging inside docker. You will need the pycharm-debug-py3k.egg for this. For me I copied to my current Dockerfile folder like below
cp "/Users/tarun.lalwani/Library/Application Support/IntelliJIdea2017.2/python/pycharm-debug-py3k.egg" .
The location for your will change based on the IntelliJ version installed. After that, we need to edit our Dockerfile
FROM python:3.6
WORKDIR /app
ENV PYTHONPATH=/app:/app/debug
COPY pycharm-debug-py3k.egg /app/debug
COPY debug_test.py /app/
CMD python debug_test.py
The debug_test.py when built will have below lines at the top
import pydevd
pydevd.settrace('docker.for.mac.localhost', port=55507, stdoutToServer=True, stderrToServer=True)
Note: I have used docker.for.mac.localhost as I use docker for mac, but if use Docker for windows then use docker.for.win.localhost. For toolbox or linux you will add the IP of your machine
Since it is docker, we probably want to keep port fixed instead of dynamic like I did. Now we build the docker file and run it.
This will open a popup in pycharm, click autodetect to detect the source mappings
And then you will have your code breakpointed at the main line of your file

Problems connecting pycharm to remote interpreter via docker

I'm trying to connect pycharm 2016.2 professional to remote python interpreter via docker. I have docker for windows version 1.12.0-rc2-beta20 (the one that uses hyper-v on windows 10; not virtualbox). In pycharm, there's dialog that asks for the docker API URL which is by default populated with: https://192.168.99.100:2376
But that doesn't connect. I also tried localhost:2376 and 10.0.75.0:2376 (10.0.75.0 is the internal IP for vEthernet (DockerNAT)) and they do not work. Is the integration just not supported with the non-virtualbox docker or am I entering the wrong thing?

Configuring an external launcher for Eclipse over SSH with pydev

Hoping that this is the right place to ask this:
I have my Eclipse-Python IDE with PyDev on my windows machine.
My codes/project files are on my Rasp-Pi (Remote machine)
I connect the Eclipse with "Remote System Explorer" Addon via SSH.I can work on the remote code and execute it over the SSH-Terminal (or Putty) so far it works good.
Now I fail at configuring a remote launcher for the project. I just want to run/debug project within Eclipse-IDE (i.e. just via shortcut-key F11) and the Remote machine (Rasp-Pi) executes the code and does stuff.
I dream about a configuration field like
(ssh pi#0.00.00.00 &) python %1
EDIT
I am able to run my script remotely via a command prompt. All I want to do is to run the scripts with the standard launcher of eclipse configuring it, see pics.

python, django, vagrant and access error on windows host machine

Well, I'm trying to access a python server (for django development) in a Virtual Box VM via vagrant, but I can't connect with it in my windows browsers. I'll try to describe all the things I've done to make this work, so maybe it can help you guys.
My configurations:
I set my vagrant file to allow connections in port 8000 (guest and host)
I have disabled my windows firewall.
I have turned off the firewall on the VM
I have disabled all chrome extensions (including addblock)
I have disabled almost all apps in my windows to minimize the chances that some program could use port 8000
I have unchecked "automatically detect settings" and "use a proxy server for your lan" in the lan settings (windows internet options), then done the ip /release, ip /renew and rebooted my machine
Yes, the python server is running well on the vm
I tried the default 127.0.0.1:8000 (no success) and changed to 0.0.0.0:8000 using the command "python manage.py runserver 0.0.0.0:8000", but still ... :(
I have a nginx server in the vm running well for my php apps in port 80, and i cant access them with no problems
I use pycharm for python development and it starts my server normally in the vm either using 127.0.0.1:8000 or 0.0.0.0:8000
I think that's it, but the error persists, I can't access my python server in my ip 192.168.56.101 in port 8000, this ip is my private network on the vm that runs good with nginx.
But the result is always the same
Whenever I try access http://192.168.56.101:8000/ all my browsers (IE, Firefox, Chrome) cannot complete the request, in Chrome the error is ERR_CONNECTION_TIMED_OUT
Thanks in advance for any help !
My problem was the firewall rules. I dont really need it since its a development environment, so I delete all the rules in /etc/iptables/rules.v4 and save the file. That solve it all. Tks.

Categories

Resources