I can't get Python debugger to work on PyCharm 2022.1.2 with Django 4.
When I set the breakpoint inside the view function and then call this view in the browser, nothing happens when started in debug mode...
breakpoint_selected
However breakpoint is hit when I set it for import.
breakpoint_hit
I have 2 configurations, one for Python and one for Django Server, both don't work.
config1
config2
Went through numerous JetBrains tickets with people reporting similar problem but didn't find the solution there. Also tried creating second run configuration, for Python instead Django Server, but this also didn't help.
Solved this by deleting the .idea directory from top-level django project dir. Not sure what were the mechanics behind it, but it worked and now breakpoints work perfectly.
Related
I'm developing a Python app for AppEngine using Eclipse / Pydev and need to debug with persistent data stored in the local NDB.
Now, the default path for the NDB on my Linux machine is /tmp and this gets discarded after each reboot. I couldn't find a way to tell Eclipse to use a custom path for the NDB, so I finally resorted to starting the dev_appserver.py via the terminal with:
dev_appserver.py --datastore_path=/home/myfolder/workspace/myapp_datastore app.yaml
Now when I start the debugger I really need persistent data to trace some tricky bugs, but as mentioned, I couldn't find a way to tell eclipse where to store the local NDB so as a consequence I can't use the debugger with persistent data.
Anybody knows a solution?
Tks!
Note: I'm a PyCharm, not an Eclipse user, the answer is based on info I saw.
A Run Configuration window with an Arguments tab allowing you to configure optional arguments for dev_appserver.py is mentioned in the (rather old) Cant Run Google appengine python app on eclipse although launcher works fine, but confirmed in 4.4. Run your application:
You still can use the command line to run your GAE application. But we
are now going to configure Eclipse to allow you to run your
application directly from Eclipse. Right-click on "todo.py", select
Run As ▸ Run Configuration. Under Main Module maintain the path to
dev_appserver.py.
Switch to the argument tab and maintain the full path name of your
project as a parameter. Put the parameter in double-quotes.
I agree, these are Run Configurations and you're asking about configuration for debugging the app. Well, at least in PyCharm they apply to running through the debugger as well, they're actually called Run/Debug Configurations.
Maybe the same applies to Eclipse as well, so IMHO it's worth to locate this tab in your Eclipse version and configure in it the arguments you desire, then check if they apply in the debugger.
My app is pretty slow even in a dev environment so I would like to figure out what's slowing it down so I can try and fix it.
I know about the debug toolbar and according to what it reports neither the database queries nor the downloaded sources are the issue, so it must be the business logic.
However, I cannot run the PyCharm profiler with the Django server because, well, it's not like running a script.
How may I profile Django with PyCharm?
You should probably set configuration properly.
Then click on Edit Configurations...
The main thing is to set Interpreter (your virtual environment). You don't have to set Custom Run Command if you use python manage.py runserver
Then you can run Django server directly from PyCharm ann Profiler too.
A little background:
I've been working on this project for about six months now and it's been running on Flask the whole time. Everything has been fine, multiple versions of the backend have been deployed live to support an app that's been in production for months now.
The development cycle involves writing everything locally and using Flask-Script's runserver command to test everything locally on localhost:8080 before deploying to a dev server and then finally to the live server.
The Problem: The other day my local flask instance, which runs on localhost:8080 apparently stopped respecting my local files.
I tried adding a new view (with a new template) and I got a 404 error when trying to view it in my browser.
I then tried making some test changes to one of the existing pages by adding a few extra words to the title. I restarted flask and none of those changes appeared.
I then went as far as deleting the entire views.py file. After restarting flask again, much to my dismay, I could still view the pages that were there originally (i.e. before this behavior started).
Finally, I made some changes to the manage.py file, which is where I put all of the Flask-Script commands, and they weren't recognized either. It's as if flask started reading from a cached version of the filesystem that won't update (which very well might be the case but I have no idea why it started doing this or how to fix the issue).
FYI: Browser caching shouldn't be an issue b/c I have the dev tools open with caching disabled. Plus the fact that changes to manage.py aren't being noticed shouldn't have anything to do with the browser.
You've most likely used flask in the DEBUG mode in which it auto reloads templates the app whenever a file changes.
Try using
export FLASK_DEBUG=True
before running
flask run
For more information see http://flask.pocoo.org/docs/1.0/config/#DEBUG
I was having a similar issue and deleting the .pyc files solved it for me.
I just managed to get debugging my django site 'kind of' working in Eclipse. All my breakpoints get caught just fine, but I have to restart the server every time I make a code change. I think this is because I'm using the --noreload argument when kicking off the server.
Is there any way to setup Eclipse debugging so that I can change code, and continue execution, with my changes being reflected in the django site straight away?
Cheers,
Dave
Trindaz on Fedang #django
This is a bit late, but in case someone else comes looking for a solution to the same problem:
This video was very helpful when I was trying to setup Django Eclipse debugging with autoreload i.e. without using the --noreload switch. It pretty much walks you through the steps with a couple of helpful pointers. I've set up twice myself using this video.
The manage.py replacement code can be obtained from http://djangosnippets.org/snippets/1561/
I found these links through the poster's blog post which seems to be down at the moment, hence the direct links
EDIT: A patch may be required to Django 1.3 to run in autoreload mode from inside an IDE. See PyCharm manage.py runserver error for more information.
http://bear330.wordpress.com/2007/10/30/how-to-debug-django-web-application-with-autoreload/
Author explains how to do so here, basically you have to embed the remote debugger into your manage.py file.
Hope this helps
I detected this problem when updating the patterns in URLConf and seeing that the new pattern wasn't matched anywhere.
So, with urls.py I don't get anywhere when writing random lines on it, I mean, invalid code, and django doesn't throw any exception and serves the urls just fine.
So I checked ROOT_URLCONF in settings.py, and it points to "projectname.urls" so it's reading the right file. I tried deleting urls.py, and the server keeps running and serving just fine. Then I deleted settings.py, just to see if it wasn't being read, and that gave me the expected exception.
I deleted all *.pyc too, restarted runserver many times, and even restarted the whole computer. I also tried deleting the db and running syncdb again.
I created a new empty project, and it runs just fine.
I'm running the latest development version:
Django version 1.2 beta 1 SVN-12617, using settings 'cms.settings'
I am asking for any kind of help of how to override this behavior, I mean, there must be something that's misconfigured.
You're not running what you think you're running. Check your PYTHONPATH.