PyCharm Debugger Lines Are Out Of Sync With Reality












3















I'm using Django Rest Framework 3.5.4 and Pycharm Professional 2016.3.1. Incidentally, I have PyCharm configured to use a virtualenv inside a local vagrant box.



When I step through the DRF code with the debugger on, I can see that it is stepping through blank lines, and the variables in the debugger don't match those in scope (pictured here is rest_framework.response.Response.rendered_content()):



breakpoint on blank line



Here's another example that shows how variables in scope in the debugger don't match the single variable passed in. Also, note how the breakpoint is clearly on a docstring:



enter image description here



This is not the first time I have seen this in PyCharm; while viewing the library source usually works, occasionally I will see a mismatch between the source caches and what is being executed.



My question is: how can I correct this behavior? I have tried blowing away my virtualenv and then rebuilding it and reassociating it with PyCharm. I have also tried File > Invalidate Caches / Restart and in this particular case neither have helped.



EDIT:



I thought I had solved this issue by removing all of the ~/Library/Caches/PyCharmXX/remote_sources/* files, re-invalidating the caches, restarting PyCharm, and re-associating the remote interpreter with the project. The next time I tried debugging the same file, I was given a screen to select the sources. I clicked auto-detect and noticed that two versions were available:



select local file for the file from remote host



I did a diff between the two that were available, and there was no difference. Also, the number of bytes and the modification times were the same in each file:



pnore at pnore-mbp in ~/Library/Caches
$ ls -l PyCharm2016.3/remote_sources/974253138/308149114/rest_framework/serializers.py
-rw-r--r-- 1 pnore HBSDomain Users 60495 Mar 7 16:56 PyCharm2016.3/remote_sources/974253138/308149114/rest_framework/serializers.py

pnore at pnore-mbp in ~/Library/Caches
$ ls -l PyCharm2016.3/remote_sources/974253138/-328085538/rest_framework/serializers.py
-rw-r--r-- 1 pnore HBSDomain Users 60495 Mar 7 16:56 PyCharm2016.3/remote_sources/974253138/-328085538/rest_framework/serializers.py

pnore at pnore-mbp in ~/Library/Caches
$ diff PyCharm2016.3/remote_sources/974253138/308149114/rest_framework/serializers.py PyCharm2016.3/remote_sources/974253138/-328085538/rest_framework/serializers.py
[no output]


I arbitrarily chose the latter one, and subsequently, debugging line numbers appeared to match up for that file. I believe the problem was that a previous version of PyCharm had associated that path file with a cached old version of the library. I do not know why invalidate caches on its own did not solve the issue.



Unfortunately, the association does NOT remain in PyCharm across debugging sessions. This means that the every file needs to be re-associated for every debugging session; something is clearly wrong.










share|improve this question





























    3















    I'm using Django Rest Framework 3.5.4 and Pycharm Professional 2016.3.1. Incidentally, I have PyCharm configured to use a virtualenv inside a local vagrant box.



    When I step through the DRF code with the debugger on, I can see that it is stepping through blank lines, and the variables in the debugger don't match those in scope (pictured here is rest_framework.response.Response.rendered_content()):



    breakpoint on blank line



    Here's another example that shows how variables in scope in the debugger don't match the single variable passed in. Also, note how the breakpoint is clearly on a docstring:



    enter image description here



    This is not the first time I have seen this in PyCharm; while viewing the library source usually works, occasionally I will see a mismatch between the source caches and what is being executed.



    My question is: how can I correct this behavior? I have tried blowing away my virtualenv and then rebuilding it and reassociating it with PyCharm. I have also tried File > Invalidate Caches / Restart and in this particular case neither have helped.



    EDIT:



    I thought I had solved this issue by removing all of the ~/Library/Caches/PyCharmXX/remote_sources/* files, re-invalidating the caches, restarting PyCharm, and re-associating the remote interpreter with the project. The next time I tried debugging the same file, I was given a screen to select the sources. I clicked auto-detect and noticed that two versions were available:



    select local file for the file from remote host



    I did a diff between the two that were available, and there was no difference. Also, the number of bytes and the modification times were the same in each file:



    pnore at pnore-mbp in ~/Library/Caches
    $ ls -l PyCharm2016.3/remote_sources/974253138/308149114/rest_framework/serializers.py
    -rw-r--r-- 1 pnore HBSDomain Users 60495 Mar 7 16:56 PyCharm2016.3/remote_sources/974253138/308149114/rest_framework/serializers.py

    pnore at pnore-mbp in ~/Library/Caches
    $ ls -l PyCharm2016.3/remote_sources/974253138/-328085538/rest_framework/serializers.py
    -rw-r--r-- 1 pnore HBSDomain Users 60495 Mar 7 16:56 PyCharm2016.3/remote_sources/974253138/-328085538/rest_framework/serializers.py

    pnore at pnore-mbp in ~/Library/Caches
    $ diff PyCharm2016.3/remote_sources/974253138/308149114/rest_framework/serializers.py PyCharm2016.3/remote_sources/974253138/-328085538/rest_framework/serializers.py
    [no output]


    I arbitrarily chose the latter one, and subsequently, debugging line numbers appeared to match up for that file. I believe the problem was that a previous version of PyCharm had associated that path file with a cached old version of the library. I do not know why invalidate caches on its own did not solve the issue.



    Unfortunately, the association does NOT remain in PyCharm across debugging sessions. This means that the every file needs to be re-associated for every debugging session; something is clearly wrong.










    share|improve this question



























      3












      3








      3








      I'm using Django Rest Framework 3.5.4 and Pycharm Professional 2016.3.1. Incidentally, I have PyCharm configured to use a virtualenv inside a local vagrant box.



      When I step through the DRF code with the debugger on, I can see that it is stepping through blank lines, and the variables in the debugger don't match those in scope (pictured here is rest_framework.response.Response.rendered_content()):



      breakpoint on blank line



      Here's another example that shows how variables in scope in the debugger don't match the single variable passed in. Also, note how the breakpoint is clearly on a docstring:



      enter image description here



      This is not the first time I have seen this in PyCharm; while viewing the library source usually works, occasionally I will see a mismatch between the source caches and what is being executed.



      My question is: how can I correct this behavior? I have tried blowing away my virtualenv and then rebuilding it and reassociating it with PyCharm. I have also tried File > Invalidate Caches / Restart and in this particular case neither have helped.



      EDIT:



      I thought I had solved this issue by removing all of the ~/Library/Caches/PyCharmXX/remote_sources/* files, re-invalidating the caches, restarting PyCharm, and re-associating the remote interpreter with the project. The next time I tried debugging the same file, I was given a screen to select the sources. I clicked auto-detect and noticed that two versions were available:



      select local file for the file from remote host



      I did a diff between the two that were available, and there was no difference. Also, the number of bytes and the modification times were the same in each file:



      pnore at pnore-mbp in ~/Library/Caches
      $ ls -l PyCharm2016.3/remote_sources/974253138/308149114/rest_framework/serializers.py
      -rw-r--r-- 1 pnore HBSDomain Users 60495 Mar 7 16:56 PyCharm2016.3/remote_sources/974253138/308149114/rest_framework/serializers.py

      pnore at pnore-mbp in ~/Library/Caches
      $ ls -l PyCharm2016.3/remote_sources/974253138/-328085538/rest_framework/serializers.py
      -rw-r--r-- 1 pnore HBSDomain Users 60495 Mar 7 16:56 PyCharm2016.3/remote_sources/974253138/-328085538/rest_framework/serializers.py

      pnore at pnore-mbp in ~/Library/Caches
      $ diff PyCharm2016.3/remote_sources/974253138/308149114/rest_framework/serializers.py PyCharm2016.3/remote_sources/974253138/-328085538/rest_framework/serializers.py
      [no output]


      I arbitrarily chose the latter one, and subsequently, debugging line numbers appeared to match up for that file. I believe the problem was that a previous version of PyCharm had associated that path file with a cached old version of the library. I do not know why invalidate caches on its own did not solve the issue.



      Unfortunately, the association does NOT remain in PyCharm across debugging sessions. This means that the every file needs to be re-associated for every debugging session; something is clearly wrong.










      share|improve this question
















      I'm using Django Rest Framework 3.5.4 and Pycharm Professional 2016.3.1. Incidentally, I have PyCharm configured to use a virtualenv inside a local vagrant box.



      When I step through the DRF code with the debugger on, I can see that it is stepping through blank lines, and the variables in the debugger don't match those in scope (pictured here is rest_framework.response.Response.rendered_content()):



      breakpoint on blank line



      Here's another example that shows how variables in scope in the debugger don't match the single variable passed in. Also, note how the breakpoint is clearly on a docstring:



      enter image description here



      This is not the first time I have seen this in PyCharm; while viewing the library source usually works, occasionally I will see a mismatch between the source caches and what is being executed.



      My question is: how can I correct this behavior? I have tried blowing away my virtualenv and then rebuilding it and reassociating it with PyCharm. I have also tried File > Invalidate Caches / Restart and in this particular case neither have helped.



      EDIT:



      I thought I had solved this issue by removing all of the ~/Library/Caches/PyCharmXX/remote_sources/* files, re-invalidating the caches, restarting PyCharm, and re-associating the remote interpreter with the project. The next time I tried debugging the same file, I was given a screen to select the sources. I clicked auto-detect and noticed that two versions were available:



      select local file for the file from remote host



      I did a diff between the two that were available, and there was no difference. Also, the number of bytes and the modification times were the same in each file:



      pnore at pnore-mbp in ~/Library/Caches
      $ ls -l PyCharm2016.3/remote_sources/974253138/308149114/rest_framework/serializers.py
      -rw-r--r-- 1 pnore HBSDomain Users 60495 Mar 7 16:56 PyCharm2016.3/remote_sources/974253138/308149114/rest_framework/serializers.py

      pnore at pnore-mbp in ~/Library/Caches
      $ ls -l PyCharm2016.3/remote_sources/974253138/-328085538/rest_framework/serializers.py
      -rw-r--r-- 1 pnore HBSDomain Users 60495 Mar 7 16:56 PyCharm2016.3/remote_sources/974253138/-328085538/rest_framework/serializers.py

      pnore at pnore-mbp in ~/Library/Caches
      $ diff PyCharm2016.3/remote_sources/974253138/308149114/rest_framework/serializers.py PyCharm2016.3/remote_sources/974253138/-328085538/rest_framework/serializers.py
      [no output]


      I arbitrarily chose the latter one, and subsequently, debugging line numbers appeared to match up for that file. I believe the problem was that a previous version of PyCharm had associated that path file with a cached old version of the library. I do not know why invalidate caches on its own did not solve the issue.



      Unfortunately, the association does NOT remain in PyCharm across debugging sessions. This means that the every file needs to be re-associated for every debugging session; something is clearly wrong.







      debugging django-rest-framework pycharm






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 '17 at 19:00







      P. Myer Nore

















      asked Mar 7 '17 at 14:55









      P. Myer NoreP. Myer Nore

      2,32412840




      2,32412840
























          2 Answers
          2






          active

          oldest

          votes


















          0














          I had a similar issue, two files with the same path and the debugger was using the wrong one, though in my case the files did differ slightly.



          The fix was as follows on Windows with PyCharm 2017.2.3:




          1. Exit PyCharm.

          2. Remove folders leftover from previous versions of PyCharm. In my case there was both .PyCharm2017.2 and .PyCharm2017.1 folders.

          3. Restart PyCharm.

          4. Debug again, select auto-detect when prompted to select the correct source.






          share|improve this answer































            0














            set "path mappings" in the debug configuration






            share|improve this answer























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42651430%2fpycharm-debugger-lines-are-out-of-sync-with-reality%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              I had a similar issue, two files with the same path and the debugger was using the wrong one, though in my case the files did differ slightly.



              The fix was as follows on Windows with PyCharm 2017.2.3:




              1. Exit PyCharm.

              2. Remove folders leftover from previous versions of PyCharm. In my case there was both .PyCharm2017.2 and .PyCharm2017.1 folders.

              3. Restart PyCharm.

              4. Debug again, select auto-detect when prompted to select the correct source.






              share|improve this answer




























                0














                I had a similar issue, two files with the same path and the debugger was using the wrong one, though in my case the files did differ slightly.



                The fix was as follows on Windows with PyCharm 2017.2.3:




                1. Exit PyCharm.

                2. Remove folders leftover from previous versions of PyCharm. In my case there was both .PyCharm2017.2 and .PyCharm2017.1 folders.

                3. Restart PyCharm.

                4. Debug again, select auto-detect when prompted to select the correct source.






                share|improve this answer


























                  0












                  0








                  0







                  I had a similar issue, two files with the same path and the debugger was using the wrong one, though in my case the files did differ slightly.



                  The fix was as follows on Windows with PyCharm 2017.2.3:




                  1. Exit PyCharm.

                  2. Remove folders leftover from previous versions of PyCharm. In my case there was both .PyCharm2017.2 and .PyCharm2017.1 folders.

                  3. Restart PyCharm.

                  4. Debug again, select auto-detect when prompted to select the correct source.






                  share|improve this answer













                  I had a similar issue, two files with the same path and the debugger was using the wrong one, though in my case the files did differ slightly.



                  The fix was as follows on Windows with PyCharm 2017.2.3:




                  1. Exit PyCharm.

                  2. Remove folders leftover from previous versions of PyCharm. In my case there was both .PyCharm2017.2 and .PyCharm2017.1 folders.

                  3. Restart PyCharm.

                  4. Debug again, select auto-detect when prompted to select the correct source.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Oct 27 '17 at 13:57









                  moderatemisbehaviourmoderatemisbehaviour

                  33310




                  33310

























                      0














                      set "path mappings" in the debug configuration






                      share|improve this answer




























                        0














                        set "path mappings" in the debug configuration






                        share|improve this answer


























                          0












                          0








                          0







                          set "path mappings" in the debug configuration






                          share|improve this answer













                          set "path mappings" in the debug configuration







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 15 '18 at 3:43









                          haohao

                          184




                          184






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42651430%2fpycharm-debugger-lines-are-out-of-sync-with-reality%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              List item for chat from Array inside array React Native

                              Thiostrepton

                              Caerphilly