# Integrate pycharm and Slicer

**URL:** <https://discourse.slicer.org/t/integrate-pycharm-and-slicer/1567>\
**Category:** Support\
**Created:** [November 30, 2017, 5:31pm UTC](https://discourse.slicer.org/t/integrate-pycharm-and-slicer/1567 "2017-11-30T17:31:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![darekdev](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@darekdev](https://discourse.slicer.org/u/darekdev)\
**Post date:** [November 30, 2017, 5:31pm UTC](https://discourse.slicer.org/t/integrate-pycharm-and-slicer/1567/1 "2017-11-30T17:31:39Z")

</div>

Operating system: Arch Linux  
Slicer version: newest  
Expected behavior: working debugging, want to use imports in pycharm and code completion  
Actual behavior: debugging doesn’t work, can’t import slicer or vtk or qt in pycharm (code completion)

Hello,

I work 2 years with Slicer and I made some modules but I can’t never integrate pycharm and Slicer-SuperBuild with 100%. What should I do? Because when I add vtk, qt, slicer paths to pycharm interpreter path that doesn’t work. Is it possible? And I can’t run debugging process. When I click connect in Slicer(debugging plugin) then nothing happen: Slicer doesn’t freeze.  
Can’t find any relevant tutorial in Internet. I appreciate any suggestion.

Thank you  
Darek

---

<div class="post-metadata">

**Author:** ![ungi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ungi/32/78573_2.png) [@ungi](https://discourse.slicer.org/u/ungi)\
**Post date:** [December 1, 2017, 4:52pm UTC](https://discourse.slicer.org/t/integrate-pycharm-and-slicer/1567/2 "2017-12-01T16:52:23Z")

</div>

Hello Darek,

I use PyCharm to debug Slicer on a daily basis. I run it on Windows, but I think it should work the same way, because python should be the same.  
There are instructions on how to set up Slicer and PyCharm on the website of the DebuggingTools extension:  
[https://www.slicer.org/wiki/Documentation/Nightly/Extensions/DebuggingTools](https://www.slicer.org/wiki/Documentation/Nightly/Extensions/DebuggingTools)  
Some important steps to do before you can use the debugger:

- In PyCharm, set up and start a “Python Remote Debug” server on localhost with a port number e.g. 5678
- In Slicer specify the egg file of PyCharm in the Python Debugger module, and set the same port number  
If the connection is successful, you will see a note in the PyCharm debugger console. And break points should work after that (no need to restart anything).

Code completion usually doesn’t work in the PyCharm code editor main window. The reason is that some python modules are loaded in runtime, so there is no way for PyCharm to know at any time what python modules are available. But if you pause the program execution with a breakpoint, you can use the debugger console to type code, and code completion will work correctly. That is because PyCharm knows at that time what modules are currently loaded.

I hope this helps,  
Tamas

---

<div class="post-metadata">

**Author:** ![Amy\_Morton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/amy_morton/32/67318_2.png) [@Amy\_Morton](https://discourse.slicer.org/u/Amy_Morton)\
**Post date:** [December 5, 2024, 4:46pm UTC](https://discourse.slicer.org/t/integrate-pycharm-and-slicer/1567/3 "2024-12-05T16:46:23Z")

</div>

@ungi  
‘If the connection is successful’

Are there troubleshooting resources when the connection is unsuccessful?

> [@Troubleshooting PyCharm Debug Egg File Path Configuration in 3DSlicer](https://discourse.slicer.org/t/troubleshooting-pycharm-debug-egg-file-path-configuration-in-3dslicer/40458/2):
>
> I’ve been experiencing similar issues getting my Slicer Python Debug connection to PyCharm up and running. Windows 10 Enterprise 19045.5131 Slicer 5.6.2 PyCharm 2024.3 (Pro) I had previously installed PyCharm 2024.2.4 and encountered the .egg issue. I also found the stackoverflow thread on extracting- but the path wath still pointed to \_attach\_proces… under the .egg dir. I uninstalled .2.4 and installed 2024.3. In PyCharm I configured the remote debugger and I successfully built…

---

<div class="post-metadata">

**Author:** ![ungi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ungi/32/78573_2.png) [@ungi](https://discourse.slicer.org/u/ungi)\
**Post date:** [December 5, 2024, 10:38pm UTC](https://discourse.slicer.org/t/integrate-pycharm-and-slicer/1567/4 "2024-12-05T22:38:02Z")

</div>

Hi Amy,  
I switched to VS Code a few years ago and I’m not using PyCharm anymore. There are some troubleshooting suggestions on this page, but I don’t remember running into such issues: [SlicerRt/SlicerDebuggingTools: Extension for 3D Slicer containing various tools for module development and debugging](https://github.com/SlicerRt/SlicerDebuggingTools)  
If you are considering switching to VS Code too, I can highly recommend it and happy to give you a demo too.  
Tamas

---

<div class="post-metadata">

**Author:** ![Amy\_Morton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/amy_morton/32/67318_2.png) [@Amy\_Morton](https://discourse.slicer.org/u/Amy_Morton)\
**Post date:** [December 6, 2024, 12:22am UTC](https://discourse.slicer.org/t/integrate-pycharm-and-slicer/1567/5 "2024-12-06T00:22:17Z")

</div>

I was previously using vs code for other python projects- I would gladly take the demo offer!

Thank you!  
Let me know when a zoom call might be convenient for you?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 6, 2024, 2:58am UTC](https://discourse.slicer.org/t/integrate-pycharm-and-slicer/1567/6 "2024-12-06T02:58:10Z")

</div>

PyCharm developers often break their debugger (happens about once a year). The problem and workaround in their latest version is described here: [Problems with Pycharm 2024.3 - Does not connect · Issue #19 · SlicerRt/SlicerDebuggingTools · GitHub](https://github.com/SlicerRt/SlicerDebuggingTools/issues/19)

I switched to VS Code a few years ago, too. PyCharm has a little extra convenience that the debugger can automatically reconnect when you restart Slicer (while if you use VS Code then you need to click to connect each time) and the PyCharm debugging console looks more like a regular Python console (while in VS Code the console has a separate single line for input, which takes some time to get used to). However, I switched to VS Code for debugging because I use VS Code for everything else anyway and remote debugging requires PyCharm professional version (you need to pay if you are not student or educator).

---

<div class="post-metadata">

**Author:** ![Amy\_Morton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/amy_morton/32/67318_2.png) [@Amy\_Morton](https://discourse.slicer.org/u/Amy_Morton)\
**Post date:** [December 6, 2024, 3:23pm UTC](https://discourse.slicer.org/t/integrate-pycharm-and-slicer/1567/7 "2024-12-06T15:23:39Z")

</div>

Thank-you both! I’ll switch to VSCode via [the instructions](https://github.com/SlicerRt/SlicerDebuggingTools/blob/master/README.md) and follow back

---

<div class="post-metadata">

**Author:** ![Amy\_Morton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/amy_morton/32/67318_2.png) [@Amy\_Morton](https://discourse.slicer.org/u/Amy_Morton)\
**Post date:** [December 6, 2024, 5:31pm UTC](https://discourse.slicer.org/t/integrate-pycharm-and-slicer/1567/8 "2024-12-06T17:31:14Z")

</div>

Hurray! VSCode was such a more straightforward configuration!

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/1/212e85a011d4d97c5577aae7f6f56476954b43d2.png)
