Is there a way to make aptana 3 autoreload when i make changes to a py file in a django project? - django

Aptana makes it open in --noreload mode automatically because not doing so causes python instances to remain open or something like that, is there anyway to bypass this problem?

As far as I know, it's not possible to auto-reload .py files within an Aptana Python run/debug configuration (which is what I'm assuming you're doing to get access to the call stack for debugging). I've been using Aptana for Python development for a couple of years, and I've yet to see a way to do this. if someone knows how, please share!

Related

spyder profiler uses wrong python

I am using a virtualenv, but I would like to use an IDE. So I pull up spyder and easily I can change the python interpreter to .virtualenv/myenv/.../python
But, when I go to "F10" for to profile my code, Spyder identifies the interpreter in usr/lib/. I couldn't find anywhere in preferences to change this.
How can I make profiler see the correct python interpreter?
-Chris
Hmm it seems like this is a bug, can you post it in the Spyder issue tracker?
You can post an issue from within Spyder itself in the help menu click on "Report issue

Pycharm debugger does not stop on breakpoints

I have a flask project I am trying to debug (this was working absolutely ok till few hours ago) - When I debug the project, I see the following :
Connected to pydev debugger (build 135.1057)
/Users/vantani/cp/bin/python /Applications/PyCharm.app/helpers/pydev/pydevd.py --multiproc --save-
signatures --client 127.0.0.1 --port 49223 --file /Users/vantani/cp/unnamed/manage.py server
pydev debugger: process 484 is connecting
/Users/vantani/cp/lib/python2.7/site-packages/flask_cache/__init__.py:152: UserWarning: Flask-
Cache: CACHE_TYPE is set to null, caching is effectively disabled.
warnings.warn("Flask-Cache: CACHE_TYPE is set to null, "
* Running on http://127.0.0.1:5000/
* Restarting with reloader
pydev debugger: process 498 is connecting
As I said this setup was working fine. Now, the debugger does not stop at the breakpoint and the debugger window is empty. I see that there are two processes created by PyDev and I guess that is causing this issue. I have restarted my machine and there is only one pycharm process running.
Sometimes this might be caused by the fact that some other module is using the same tracing api (sys.settrace) as debugger, for instance Coverage.py. The solution would be to go to your Rub/Debug Configurations and add --no-cov flag to the Additional Arguments.
Alternatively you might want to delete all --cov in pytest settings (i.e. pytest.ini) or run tests with --no-cov flag, i.e.
pytest test.py --no-cov
It might be also caused by a bad filename, e.g. your file/directory has special characters or spaces in it. Try removing them or changing to e.g. underscore (_).
There is an issue with the debugger in PyCharm lately.
I'm on mac using PyCharm 2020.2 and while the debugger would stop at tests, it wouldn't stop when running the dev server for django.
For me disabling Gevent compatible option in Preferences > Build, Execution, Deployment has helped.
Worth noting that some suggest to enable some suggest to disable that option - so it's worth having a go at each and see if that helps your case.
Just need set flask's debug mode off, such as
app.run(debug=False)
I didn't have a flask project but I had the same problem. In my case I had to change the project-path! There were umlauts (ü,ä,ö) in it. By removing them the breakpoints worked again.
My problem is solved when I installed pydevd-pycharm
pip install pydevd-pycharm
Also here is a useful link for this problem.
github from jetbrains intellij-community
Check your python debugger settings, and clear your cache, This helped me
The following workaround should help. I had a same problem in a simple Python script. PyCharm debugger didn't stop on a simple breakpoint and just ran to the end.
Thanks to Gabriel's answer, I checked the path to my script and it had Russian letters. Because I use Russian Windows and it creates admin user named 'Administrator' using Russian letters.
I changed the Russian letters to use only English letters from the project-path (just copied PyCharm projects folder to the root of disk and reloaded my project from new place. Nothing else was changed!). And the debugger immediately started working just fine and stopped on breakpoints!
It looks like this a bug that PyCharm debuger can't work with different national letters in the path. It very common situation outside English-speaking countries.
For Sanic case.
Run go_fast(..auto_reload=False,..).
There is a long thread about this issue on JetBrains forums:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/360008107400-PyCharm-2020-1-not-stopping-on-breakpoints-anymore-. Reading through that thread is like reading a black magic book, everyone has their own voodoo $^$#
I ran into this issue with 2021.1.1 CE and a brand new project. My solution was to change the default test runner to pytest. YMMV. If that thread is any indication, debugging might stop working if it rains tomorrow.
For me I deleted project from "recent projects in pycharm" then I opened project direct from repository. It works again.
Had the same issue recently (July 2021 PyCharms 2021.1.3 CE) for days trying everything I could find online would not work. Then found under File --> Manage IDE Settings --> Restore Default Setting, that fixed the issue for me.
For all those people that have the same problem, but can't resolve it, maybe this will work:
The problem could be, that pydev isn't connecting to its subprocess.
Check if the option "Attach to subprocess automatically while debugging?" in the debugger settings is set. You can find it in File > Settings > Build, Execution, Deployment > Python Debugger (current version of PyCharm)
Usually there is also a short hint in the console but I didn't notice it.
After removing debug_toolbar middleware the debugger is back to normal.
It's happening because of a third party module. I tried all the solutions listed and none worked for me.
I changed the interpreter that I'm using and it's working.
I had this issue when running remote interpreter from docker-compose. It disappeared when I set Working directory to my project root directory in Run/Debug Configuration. I also restarted Pycharm and invalidated caches.
I got it fixed by removing coverage config from pytest.ini
Not exactly the same case but, if you are using the Debug Server to debug a docker container, the only thing which made the breakpoint to stop for me is to set and environment variable for the container:
PYCHARM_DEBUG=True
PyCharm Version: 2022.2.2
For me PyCharm actually executed a different file. If you just clicked the run button... try if it makes a difference if you use
right click on file => Run 'xy'.
Or double check if your file full path to be executed is specified in "Script path" in the run configuration. I used to use the file name in "interpreter option" along with "working directory" specified. It would work that way.

How to configue Pydev test runner to use Docker

I am developing a Django app or two using pydev as my IDE. I like it a lot :) However, I recently got really excited about Docker and am using Docker and Fig to serve my application now. My problem is that I would like to run my tests in this build environment- seems like this is kinda the point after all!
I know how to actually do it.
fig run web python3 /code/manage.py test
would run the tests. If I didn't want to use the Django runner, I could run
fig run web python3 /code/myapp/tests.py
Either way though, I cannot figure out how to issue that command from the IDE. All of the run configurations point to the configured python.exe ... does anyone know if there is a way to replace that with a fully customized command?
Well, the PyDev launch configuration is really targeted towards running Python, but there are alternatives to running it through other ways:
Create an external tool run (run > external tools > external tools configuration): You should be able to run anything you want from there... the downside is that this isn't really integrated into PyDev, so, if you have stack-traces they won't be clickable (and you won't be able to debug either).
Create a launcher script which in turn uses subprocess to launch the command you want... if you redirect things tracebacks should be clickable. The downside is that you won't be able to create a debug session either -- but you can still use the remote debugging in this case (http://pydev.org/manual_adv_remote_debugger.html)
Improve PyDev to do that better... (i.e.: get the code: http://pydev.org/developers.html and add docker support to a project through fig -- it should be something close to org.python.pydev.django which has special integration for running in django -- with some tweaks to the start command line, even starting in debug mode directly can work here)... if you decide to go that route, you can create a feature request at https://sw-brainwy.rhcloud.com/tracker/PyDev/ and ask code-related stuff and I'll help :)
Possibly you can create a custom executable which acts like Python but in reality just forwards things to other places (i.e.: to fig run) -- I haven't actually tested this, but in theory it should work (in the past there was work to support dummy 'python' runners such as that -- i.e.: for supporting http://cctbx.sourceforge.net/ -- so, it should work -- but you still have to create this launcher script for your use case to pass things to fig run). If the work is done properly, the debugger could work here too.

Powerful Debuggers for Django

The Django debugger is absolutely dreading and finding errors is a daunting task.
Are there any third party Django debuggers out there?
I don't know about Django debuggers, but PyCharm by JetBrains is an awesome Python IDE with a built-in debugger. I've been using it for over 2 years (previously a decade long user of their awesome IntellJ Java IDE) for Django work and it's been worth every penny paid.
Pydevd plugin for eclipse supports debugging code run from outside the IDE. I find it works great with Django.
It's simple to use - start the debugger from eclipse, then add the line import pydevd;pydevd.settrace() and execution will break at that line, allowing you to step through etc from eclipse.
To debug code on a remote machine, include the ip address of the machine running eclipse as an argument to settrace() (ie import pydevd;pydevd.settrace('10.0.0.68')).
Obviously the pydevd module will neeed to be on your pythonpath.
For installation instructions check the docs.

Eclipse/PyDev + Django debug

Eclipse/PyDev, Python 2.6, Django 1.1
All is working in run mode. If I put debug point inside manage.py file, breakpoint worked. But when I putted it in any action method, it causes nothing :(
Usually the problem is that you're running with auto-reload in django, in which case a different process is actually feeding the pages, so, you need to run it with the no reload option or use the remote debugger.
(To configure PyDev to work with Django see: http://pydev.org/manual_adv_django.html)
Note that if you want to execute without the auto-reload feature (which PyDev should do automatically when you create a new Django run), you can do all directly (i.e.: the debugger and launching don't need any special adjustments).
Note: the situation has improved a bit recently, so, although the above answer is still valid, there are improvements for those that do want to develop with auto-reload on:
Answer with auto-reload on:
If you want to have auto-reload on while developing, use the tips at: PyDev and Django: how to restart dev server? (to overcome an issue where Django will leave child processes alive when the main process is killed)
And see the session related to the remote debugger at: http://pydev.org/manual_adv_remote_debugger.html to see how to attach the debugger to PyDev when using the auto-reload feature (mainly, you'll need to start the remote debugger, but will add breakpoints regularly and PyDev will stop on those provided you call pydevd.patch_django_autoreload() before you main session -- i.e.: before if __name__ == "__main__":, add the following: import pydevd;pydevd.patch_django_autoreload()).
also if while attempting to import pydevd eclipse can't find the pydevd depependency. Make sure to add it from your plugins folder:
Look for your eclipse/plugins/org.python.pydev_x.x.x/pysrc where x.x.x is your eclipse pydev plugin version. In the eclipse/plugins folder you will find lot's of folders that start with a similar name only one of them will have a pysrc subfolder(and the right version number).
Add eclipse/plugins/org.python.pydev_x.x.x/pysrc to your project's external libraries:
Right click on your project explorer.
Go to properties/PyDev - PYTHONPATH/External Libraries/ and click on Add Source folder.
Find your eclipse/plugins/org.python.pydev_x.x.x/pysrc folder on the provided browser.