You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-32Lines changed: 32 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,6 @@
1
1
# Blender Debugger for VS Code (and Visual Studio)
2
2
3
-
Inspired by [Blender-VScode-Debugger](https://github.com/Barbarbarbarian/Blender-VScode-Debugger) which was itself inspired by this [remote_debugger](https://github.com/sybrenstuvel/random-blender-addons/blob/master/remote_debugger.py) for pycharm as explained in this [Blender Developer's Blog post](https://code.blender.org/2015/10/debugging-python-code-with-pycharm/).
4
-
3
+
Inspired by [Blender-VScode-Debugger](https://github.com/Barbarbarbarian/Blender-VScode-Debugger) which was itself inspired by this [remote_debugger](https://github.com/sybrenstuvel/random-blender-addons/blob/master/remote_debugger.py) for pycharm as explained in this [Blender Developer's Blog post](https://code.blender.org/2015/10/debugging-python-code-with-pycharm/).
5
4
6
5
Since the VS Code one wasn't really well documented and it looked kind of dead, once I figured it out, I was just going to add the documentation, but then I ended up rewriting the whole thing.
7
6
@@ -17,12 +16,14 @@ Now it can:
17
16
18
17
I have made a video (click the image below) for those who just started messing with python in Blender or programming in general, but if you're semi-familiar with Python, VS Code, and the command line the following should make sense. If you have any questions or suggestions, don't hesitate to file an issue.
19
18
20
-
<strong>NOTE: ptvsd doesn't have to be version 3.0.0 anymore, so you can now ignore that and just `pip install ptvsd`</strong>
19
+
#### NOTES/EDITS
20
+
- ptvsd doesn't have to be version 3.0.0 anymore, so you can now ignore that and just `pip install ptvsd`
21
+
- This video was done with blender 2.79, but everything still works 99% the same. I think the only change is that blender changed the default shortcut to the search menu.
21
22
22
23
<palign="center"style="position:relative;">
23
-
<ahref="https://www.youtube.com/watch?v=UVDf2VSmRvk"title="Click to go to Video">
@@ -34,12 +35,12 @@ If you download the add-on from the releases page, please make sure to rename th
34
35
## Installing Python and Getting PTVSD
35
36
36
37
Install Python 3 with pip and check add to PATH.<supid="n1">[1](#f1)</sup>
37
-
- If you already have python installed and you can run it from the command line (aka PATH is set), the addon should find it. It checks `where python` or `whereis python` or `which python` to try and determine where python is and uses the first path given<supid="n2">[2](#f2)</sup>.
38
-
- If you are using something like Conda and want to use a virtual environment, to have the addon auto-detect the path you can: activate the environment, run Blender from the command line, and it should work.
38
+
- If you already have python installed and you can run it from the command line (aka PATH is set), the addon should find it. It checks `where python` or `whereis python` or `which python` to try and determine where python is and uses the first path given<supid="n2">[2](#f2)</sup>.
39
+
- If you are using something like Conda and want to use a virtual environment, to have the addon auto-detect the path you can: activate the environment, run Blender from the command line, and it should work.
39
40
40
41
`pip install ptvsd`
41
-
- The following is no longer the case, the latest ptvsd version should work just fine now. <strike>Newer versions will not work, the add-on will warn you in the console if the version is above 3.0.0. Later versions aren't supported yet in VS Code, and it will throw an error when trying to connect. See [Debugging Python with VS Code](https://code.visualstudio.com/docs/python/debugging#_remote-debugging) and [#514](https://github.com/Microsoft/vscode-python/issues/514).</strike>
42
-
- For Visual Studio, later versions should work depending on the Visual Studio version. I have never used Visual Studio, but you can find more info on setting everything up here: [Remotely Debugging Python Code on Linux](https://docs.microsoft.com/en-us/visualstudio/python/debugging-python-code-on-remote-linux-machines#connection-troubleshooting). (it is not Linux specific)
42
+
- The following is no longer the case, the latest ptvsd version should work just fine now. <strike>Newer versions will not work, the add-on will warn you in the console if the version is above 3.0.0. Later versions aren't supported yet in VS Code, and it will throw an error when trying to connect. See [Debugging Python with VS Code](https://code.visualstudio.com/docs/python/debugging#_remote-debugging) and [#514](https://github.com/Microsoft/vscode-python/issues/514).</strike>
43
+
- For Visual Studio, later versions should work depending on the Visual Studio version. I have never used Visual Studio, but you can find more info on setting everything up here: [Remotely Debugging Python Code on Linux](https://docs.microsoft.com/en-us/visualstudio/python/debugging-python-code-on-remote-linux-machines#connection-troubleshooting). (it is not Linux specific)
43
44
44
45
## Setting up your Addon
45
46
@@ -50,14 +51,14 @@ In Blender go to: `User Preferences > File` and set the path to `Scripts` to the
50
51
```
51
52
Blender Stuff
52
53
└── addons
53
-
├── your-addon-folder
54
-
├── __init__.py
55
-
├── ...etc
56
-
├── another-addon
57
-
├── ...
54
+
├── your-addon-folder
55
+
├── __init__.py
56
+
├── ...etc
57
+
├── another-addon
58
+
├── ...
58
59
```
59
60
60
-
Now remove your addon from Blender if it was installed, save settings, and when you restart your addon should be installed automatically.
61
+
Now remove your addon from Blender if you had installed it manually already, save settings, and when you restart your addon should be installed automatically.
61
62
62
63
## Setting up this Addon
63
64
@@ -79,16 +80,16 @@ Install the Python extension for VS Code if you haven't already. For Visual Stud
79
80
80
81
In the lower left ([see #3 here](https://code.visualstudio.com/docs/python/python-tutorial#_prerequisites)), VS Code should have auto detected your Python install and set it as the interpreter. For Visual Studio see [Managing Python Environments](https://docs.microsoft.com/en-us/visualstudio/python/managing-python-environments-in-visual-studio).
81
82
82
-
Go to the Debugging tab and add a configuration. Pick Python. You'll want the configuration that looks like this, no need to change the defaults, you can delete the rest.
83
+
Go to the Debugging tab and add a configuration. Pick Python. You'll want the configuration that looks like this, no need to change the defaults, you can delete the rest.
83
84
84
85
```JSON
85
-
{
86
-
"name": "Python: Attach",
87
-
"type": "python",
88
-
"request": "attach",
89
-
"port": 5678, //careful, this used to be 3000 in older versions of vscode and this addon
90
-
"host": "localhost"
91
-
},
86
+
{
87
+
"name": "Python: Attach",
88
+
"type": "python",
89
+
"request": "attach",
90
+
"port": 5678, //careful, this used to be 3000 in older versions of vscode and this addon
91
+
"host": "localhost"
92
+
},
92
93
```
93
94
94
95
Now when you run the debugger with this config in Blender and VS Code the console should print "Debugger is Attached" if it was still waiting (it should still attach even if it wasn't, it just won't tell you).
@@ -108,25 +109,24 @@ From blender you can right click just about anything and click "Edit Source" to
108
109
Open the file in VS Code, connect to the debugging server, make a change and save it.
109
110
110
111
Now in Blender the text editor will show this little red button in the top left. Click that and reload the file. Then in `Text Editor > Properties` turn on `Live Edit` if you haven't already. Now to actually get Blender to detect any changes you made just type a single character (like add a space anywhere) and *then* it will detect your changes.
111
-
112
-
112
+
113
113
### Debugging/Editing Scripts
114
114
115
-
See [Issue #4](https://github.com/AlansCodeLog/blender-debugger-for-vscode/issues/4) for a workaround.
116
-
In the future if I have some time, I might see if there's something I can do to make this easier.
115
+
See [Issue #4](https://github.com/AlansCodeLog/blender-debugger-for-vscode/issues/4) for a workaround.
116
+
In the future if I have some time, I might see if there's something I can do to make this easier.
117
117
118
118
# Troubleshooting
119
119
120
120
- Check you installed the correct ptvsd version. With VS Code this should no longer be an issue, but I believe different versions of Visual Studio need different versions of ptvsd (see [Installing Python Support](https://docs.microsoft.com/en-us/visualstudio/python/installing-python-support-in-visual-studio)).
121
121
- To determine whether the problem is on Blender's side or your editor's: Close Blender and download/copy this [test script](https://gist.github.com/AlansCodeLog/ff1b246a8e31938e1c3dbfdcbb90522f) and run it with Python, and then try to connect to the server with your editor. If you're still getting problems then the problem is with VS Code, try:
122
-
- Check your detected your Python install, or set it manually.
123
-
- For VS Code try reinstalling the VS Code Python extension.
122
+
- Check your detected your Python install, or set it manually.
123
+
- For VS Code try reinstalling the VS Code Python extension.
124
124
- If you've been using this addon for a while and it's suddenly giving you a connection error, it might be because the default port has changed. VS Code's Python extension (vscode-python) has changed their default port from 3000 to 5678, so I have changed the default accordingly. I've made it configurable now though, so just check the port the addon is set to matches the one in your `launch.json` in VS Code.
125
125
126
126
Otherwise, if none of that helped, don't hesitate to file an issue.
127
127
128
128
# Notes
129
129
130
-
<aid="f1"href="#n1">1.</a> Technically, the add-on will work with Python 2 as well since it doesn't use Python itself, just the ptvsd package, so it doesn't really matter whether you installed it with Python 2 or 3 because the package is compatible with both. On the VS Code side though, the Python extension does need to know where Python is (though not ptvsd), but it will still connect if it's using Python 2, just IntelliSense recommendations the will be wrong.
130
+
<aid="f1"href="#n1">1.</a> Technically, the add-on will work with Python 2 as well since it doesn't use Python itself, just the ptvsd package, so it doesn't really matter whether you installed it with Python 2 or 3 because the package is compatible with both. On the VS Code side though, the Python extension does need to know where Python is (though not ptvsd), but it will still connect if it's using Python 2, but your IntelliSense recommendations will be wrong in VS Code.
131
131
132
-
<aid="f2"href="#n2">2.</a> The addon also detects python if PYTHONPATH is set (because Blender will add it to sys.path) or if you used the Python bundled with Blender to install ptvsd (but that's a bit of a pain because it doesn't have pip installed, you would have to install it manually).
132
+
<aid="f2"href="#n2">2.</a> The addon also detects python if PYTHONPATH is set (because Blender will add it to sys.path) or if you used the Python bundled with Blender to install ptvsd (but that's a bit of a pain because it doesn't have pip installed, you would have to install it manually).
self.report({"ERROR"}, "Couldn't detect ptvsd, please specify the path manually in the addon preferences or reload the addon if you installed ptvsd after enabling it.")
0 commit comments