AlansCodeLog/blender-debugger-for-vscode

ENONET Error

Shaba1 opened this issue · 13 comments

OS:
Windows 10 Pro 64 bit

Add-on Version:

Blender Version:
2.79

VS Code Version:

Version: 1.28.2 (system setup)
Commit: 7f3ce96ff4729c91352ae6def877e59c561f4850
Date: 2018-10-17T00:23:12.403Z
Electron: 2.0.9
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: ia32

VS Code Python Extension Version:

2018.9.2 (29 Oct 2018)

PTVSD Version:
using pip install ptvsd==3.0.0
3,0.0
According to the test ptvsd file that I downloaded
https://gist.github.com/AlansCodeLog/ff1b246a8e31938e1c3dbfdcbb90522f
from:
https://github.com/AlansCodeLog/blender-debugger-for-vscode

4.1.4

Paths listed by where python or the corresponding command:
C:\Python27\

Does VS Code / Visual Studio connect to the troubleshooting script?

Yes

Python path/interpreter detected/selected by VS Code/Visual Studio:

Notes:

I tried to connect vscode with the debugger to a bge script that I am typing in from a youtube tutorial.

https://youtu.be/epw5q2Cmdk0?list=PLMYtDzby1wdZIHi203Xv5aoxestpF1zX9

My blend file
https://drive.google.com/open?id=1p_ui-Lx_RSt7L2c0TNANAUwTVtGAQgc6
My scripts
CylinderObject.py
https://drive.google.com/open?id=1f1csAqV600ZRDBZr76I4icd5gj_UKN4S
CubeObject.py
https://drive.google.com/open?id=1N0j4jEwJmQPvS6GFcMrCbNlbRQizWgTW

After follow the instructions giving in the video I got this error.
First Error Dialog

https://drive.google.com/open?id=1y3q_8_ijJ_mYq6cB5ob7BZbWK1RgVxaI

then after restarting blender and VSC I got this error.

Second Error in VSC
https://drive.google.com/open?id=1aflokC-pVc8Szj6WaCCcDcYjzmcH8gWa

Can Someone tell me what I am doing wrongly?

Does this work for you normally for you, because when I run either script in the console it errors out and prints ImportError: No module named 'bge'.

Also, the debugger doesn't work with anonymous/standalone scripts (not packaged as an add on). See issue #4 , there's a workaround there and I have also just added instructions on the different ways you can turns scripts into addons for those that are interested.

What's weird though is you're getting an error just from trying to connect, which I do not, trying to debug a standalone script just shouldn't pause on breakpoints. You should still be able to connect.

First thank you for answering so quickly. Some addon authors/programmers just abandon their programs after posting

Does this work for you normally for you, because when I run either script in the console it errors out and prints ImportError: No module named 'bge'.

That is not surprising since if you run ANY blender script with import bge or import bpy from a command line box it will give you that error. Blender is bundled with its own python interpreter. That way people that just want to use the included scripts that come with blender do not have to download python to do it. Now where the bge and bpy module are actually on disk and how you 'expose' them to other python scripts and to the external python interpreter is beyond my knowledge. Though I am googling on how to do that.

Also, the debugger doesn't work with anonymous/standalone scripts (not packaged as an add on). See issue #4 , there's a workaround there and I have also just added instructions on the different ways you can turns scripts into addons for those that are interested.

What's weird though is you're getting an error just from trying to connect, which I do not, trying to debug a standalone script just shouldn't pause on breakpoints. You should still be able to connect.

Do ptvsd REQUIRE that you have to be on the internet or connected to some type of network in order to work?. the fact that it gives me and error dialog with a port number makes me suspect that was the problem. I tried to use the debugger with my two scripts while I was OFFLINE i.e. not connected to the internet or any other network.

I also tried running the debugger using space_view3d.py as you showed in your video and got that same dialog box.

No, it doesn't require a network, it's a local port it's using.

...and I just realized what the problem is. I think in your VS Code debug config you might have the wrong port. It should be 3000. There's an example in the documentation, just copy and paste it to be sure.

It used to be that the default port when you added a config was 3000, but now it seems they changed it to 5678.

I will change it and make it configurable in a future release just in case.

No, it doesn't require a network, it's a local port it's using.

...and I just realized what the problem is. I think in your VS Code debug config you might have the wrong port. It should be 3000.

Do you mean the "launch.json file that is written when you chose python attach? If so that file uses port 5678 not port 3000
There's an example in the documentation, just copy and paste it to be sure.

Documentation for what. pydev? VScode? ptvsd ? or your plugin?

It used to be that the default port when you added a config was 3000, but now it seems they changed it to 5678.

I will change it and make it configurable in a future release just in case.

Sorry I wasn't clearer.

Yes, in the launch.json. The port there needs to be 3000 not 5678.

Just changing that should make it work, but just to be sure, or if that doesn't work, in the readme/documentation for my addon there's an example config that should work.

Ok where is the launch.json file after I changed the port to 300

https://drive.google.com/open?id=1phsw31h7LPD-oAyH3KvA3lTK-1F5iFqG
capture_002_14112018_162611

but when I ran the debugger I still get the same error dialog box just with a different port number.

https://drive.google.com/open?id=1phsw31h7LPD-oAyH3KvA3lTK-1F5iFqG

capture_001_14112018_162559

Okay... weird. I would try:

  • Checking to see no other programs are using the port. (In Windows open the Resource Monitor => Network Tab => Listening Ports)

  • And the only other thing that pops out at me about your setup is the python version. I've had this work with python 2, but maybe that has changed. Use python 3 just to be sure.

Edit: Also try:

  • Reinstalling the vscode-python plugin. I've had this fix problems for other people before.

  • Looking over your specs again, do you have ptvsd 3.0.0 or 4.1.4? because you mentioned both of them. Or did you mean you installed 3.0.0 but the script says it's 4.1.4? ...confused. The version should be the lastest. Just to be sure, you can uninstall it, then just pip install ptvsd again.

Okay... weird. I would try:

  • Checking to see no other programs are using the port. (In Windows open the Resource Monitor => Network Tab => Listening Ports)

I checked Resource Monitor=> Network Tab= > Listening Ports. Nothing is listening on either port 3000 or port 5678

I even opened a two incoming ports on Windows Defender Firewall Just in case that was blocking things

  • And the only other thing that pops out at me about your setup is the python version. I've had this work with python 2, but maybe that has changed. Use python 3 just to be sure.

I have Python 3.7..1 exe but have not installed it yet. I have several non blender scripts and other programs that were written with python version 2.x.x. in mind and I do not want to break those. Switching to the newest python will be my last resort

Edit: Also try:

  • Reinstalling the vscode-python plugin. I've had this fix problems for other people before.

I will give this a go and see if it works.

  • Looking over your specs again, do you have ptvsd 3.0.0 or 4.1.4? because you mentioned both of them. Or did you mean you installed 3.0.0 but the script says it's 4.1.4? ...confused. The version should be the lastest. Just to be sure, you can uninstall it, then just pip install ptvsd again.

I used "pip install ptvsd" first, But that gave me several screens of errors in the command dialog box. I think did "pip install ptvsd == 3.0.0" and that worked with no errors.
"pip list" shows ptvsd as version 3.0.0

BUT when I ran the test.py script from:

https://gist.github.com/AlansCodeLog/ff1b246a8e31938e1c3dbfdcbb90522f

test.py
import ptvsd
ptvsd.enable_attach(("0.0.0.0", 3000))
print("Waiting")
ptvsd.wait_for_attach()
print("Connected")
print ("ptvsd version is: " + ptvsd.version)
input('Press Enter to Exit')

On time in the past I ran test.py and it printed a version number of 4.1.4 ???
now I cannot get the test.py script to run at all it just frezzes in the cmd.exe box and says "Waiting" and when run for Visual Studio code it shows nothing in the VSC terminal???

ptvsd cannot be 3.0.0 anymore. It needs to be the latest version since a recent VS Code release.

So that needs to be fixed first.

Pip cannot be 3.0.0 anymore. It needs to be the latest version since a recent VS Code release.

So that needs to be fixed first.

Did you mean that "ptvsd" cannot be 3.0.0 anymore?

Oops, yes, ptvsd, sorry about that.

@Shaba1 @AlansCodeLog I hit this issue yesterday and created an issue about updating the launch.json file to get it to work: #10

Does this work for you?

Since @Shaba1 hasn't replied in a while, I will close this for now. @Shaba1 if you're still having problems, just leave a comment and I'll reopen it.