Where should I download vtk, qt, and ctk from?

In my python module, where should I download vtk, qt, and ctk from? Thanks.

Also, it’s a great honor to receive new user of the month. Thank you, thank you.

1 Like

VTK is available on PyPI. For Qt and CTK we use PythonQt for Python wrapping, so they cannot be used in a standalone Python environment but you have to use them in an application, which embeds Python, such as 3D Slicer.

2 Likes

Sorry, I don’t understand this meaning. For example, in your quicksegmen code, import VTK, QT, slicer, etc., how do I need to download the package in Anaconda

Your don’t need Anaconda. All these packages are already installed in the Python environment that Slicer provides. You can install more packages using pip (instead of conda).

I want to run your program on pycahrm instead of slicer, so I need to configure the environment. Slicer I can directly install pip, but QT, CTK I use pip install qt to report an error

Setting up Slicer’s Python environment requires importing libraries, instantiating many objects and configuring them. These are implemented in C++, in SlicerApp-real.exe. If you specify in Pycharm to use PythonSlicer.exe as a Python interpreter then you can import some libraries, such as vtk, SimpleITK, etc., but not all. For example, PythonQt is not designed to be imported like that and some other libraries are not (or not fully) Python-wrapped.

Therefore, if you want to run a Python script that uses qt, ctk, or any Slicer application classes then you need to use the Python virtual environment that Slicer sets up. You can make Pycharm debugger automatically connect to it as described here, so once you set it up, it is all nice and and convenient. You can also use Slicer as a Jupyter notebook kernel if you want to run scripts interactively in Slicer’s virtual Python environment.