Slicer-Python Packages Use and Install


(Andras Lasso) #23

See more details in this post - see above.


(saima safdar) #24

Hi,
I tried to install scikit-image but this is what I get

from pip._internal import main as pipmain

>>> pipmain(['install','scikit-image'])

Collecting scikit-image

Downloading https://files.pythonhosted.org/packages/0b/77/909865af5c9dd0fae58723e599747d204586096fd56199d51c6dcb0262e7/scikit_image-0.14.0-cp27-none-win_amd64.whl (24.7MB)

Collecting dask[array]>=0.9.0 (from scikit-image)

Downloading https://files.pythonhosted.org/packages/ea/e7/f01b2e72b4c235ee23c7730424b7bb0b36f1e93c90c129a8a14d7984ba5f/dask-0.19.1-py2.py3-none-any.whl (655kB)

Requirement already satisfied: six>=1.10.0 in d:\slicer 4.9.0-2018-08-31\lib\python\lib\site-packages (from scikit-image) (1.11.0)

Collecting pillow>=4.3.0 (from scikit-image)

Downloading https://files.pythonhosted.org/packages/48/91/f058672c494e186dc900bb6253e8cbde3307da17aed0a2d1ebcfb80ab766/Pillow-5.2.0-cp27-cp27m-win_amd64.whl (1.5MB)

Collecting PyWavelets>=0.4.0 (from scikit-image)

Downloading https://files.pythonhosted.org/packages/60/b4/d54dcf1c614ddf219fbb3612e6b0981706406ef54c1d2430be2efc5084cc/PyWavelets-1.0.0-cp27-none-win_amd64.whl (4.2MB)

Collecting networkx>=1.8 (from scikit-image)

Downloading https://files.pythonhosted.org/packages/11/42/f951cc6838a4dff6ce57211c4d7f8444809ccbe2134179950301e5c4c83c/networkx-2.1.zip (1.6MB)

Collecting cloudpickle>=0.2.1 (from scikit-image)

Downloading https://files.pythonhosted.org/packages/3e/41/cf788c011bff0ccf651fea2014450547213a03b3535a0f1bf813bf119aaf/cloudpickle-0.5.5-py2.py3-none-any.whl

Requirement already satisfied: numpy>=1.11.0; extra == "array" in d:\slicer 4.9.0-2018-08-31\lib\python\lib\site-packages\numpy-1.13.1-py2.7-win-amd64.egg (from dask[array]>=0.9.0->scikit-image) (1.13.1)

Collecting toolz>=0.7.3; extra == "array" (from dask[array]>=0.9.0->scikit-image)

Downloading https://files.pythonhosted.org/packages/14/d0/a73c15bbeda3d2e7b381a36afb0d9cd770a9f4adc5d1532691013ba881db/toolz-0.9.0.tar.gz (45kB)

Collecting decorator>=4.1.0 (from networkx>=1.8->scikit-image)

Downloading https://files.pythonhosted.org/packages/bc/bb/a24838832ba35baf52f32ab1a49b906b5f82fb7c76b2f6a7e35e140bac30/decorator-4.3.0-py2.py3-none-any.whl

Building wheels for collected packages: networkx, toolz

Running setup.py bdist_wheel for networkx: started

Running setup.py bdist_wheel for networkx: finished with status 'done'

Stored in directory: C:\Users\22374464\AppData\Local\pip\Cache\wheels\44\c0\34\6f98693a554301bdb405f8d65d95bbcd3e50180cbfdd98a94e

Running setup.py bdist_wheel for toolz: started

Running setup.py bdist_wheel for toolz: finished with status 'done'

Stored in directory: C:\Users\22374464\AppData\Local\pip\Cache\wheels\f4\0c\f6\ce6b2d1aa459ee97cc3c0f82236302bd62d89c86c700219463

Successfully built networkx toolz

Installing collected packages: toolz, dask, pillow, PyWavelets, decorator, networkx, cloudpickle, scikit-image

**The script skivi.exe is installed in 'D:\Slicer 4.9.0-2018-08-31\lib\Python\Scripts' which is not on PATH.**

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Successfully installed PyWavelets-1.0.0 cloudpickle-0.5.5 dask-0.19.1 decorator-4.3.0 networkx-2.1 pillow-5.2.0 scikit-image-0.14.0 toolz-0.9.0

0

>>>

(saima safdar) #25

Hi,
I was working on jupyter with scipy and suddenly it stoped working. What happened I dont know. it was importing before but not anymore

]:

import scipy

x

1

import scipy

Out[22]:

Traceback (most recent call last): File "<string>", line 1, in <module> File "D:\Slicer 4.9.0-2018-08-31\lib\Python\Lib\site-packages\scipy\__init__.py", line 77, in <module> from . import _distributor_init ImportError: cannot import name _distributor_init

(saima safdar) #26

I successfully installed scipy used it once but now its not working:

from pip._internal import main as pipmain

>>> pipmain(['install','scipy'])

Requirement already satisfied: scipy in d:\slicer 4.9.0-2018-08-31\lib\python\lib\site-packages (1.1.0)

Requirement already satisfied: numpy>=1.8.2 in d:\slicer 4.9.0-2018-08-31\lib\python\lib\site-packages\numpy-1.13.1-py2.7-win-amd64.egg (from scipy) (1.13.1)

0

>>> import scipy

Traceback (most recent call last):

File "<console>", line 1, in <module>

File "D:\Slicer 4.9.0-2018-08-31\lib\Python\Lib\site-packages\scipy\__init__.py", line 77, in <module>

from . import _distributor_init

ImportError: cannot import name _distributor_init

(Andras Lasso) #27

Currently, you cannot import scipy into Slicer’s embedded Python interpreter. You have access to many Python libraries, you can use numpy, you can run a Jupyter kernel in Slicer’s Python interpreter, import native Python libraries, etc. but not import entire scipy.

Probably we can make Slicer’s Python interpreter compatible with all Python packages, including scipy, within 4-6 months.


(saima safdar) #28

Hi,
I need official packages of python. If I switch to ubuntu. will I be able to install any official package? is there anything I cant do in slicer on linux as compared to widows.

I am not sure of switching but without official packages (scipy, scikit-image, skfuzzy etc) I am unable to proceed with my work. Any option if I stay in windows and can still install official packages.

Thank you

Regards,
Saima Safdar


(Andras Lasso) #29

Thanks to recent developments, you can already use all these official packages on Windows. You need to implement your processing in Python CLI modules. Slicer writes all input data to files, launches your module with the active Python interpreter (it can be any Python on your computer), and when processing is completed read all the outputs. Process data in CLI module is useful anyway, as processing can run in the background, without blocking the user interface.

See White Matter Analysis extension as an example, which uses scipy, multiprocessing, xlrd, cython, joblib, … packages.

Within about 6 months, we plan to migrate Slicer to Python 3 and then we’ll be able to load any binary Python packages directly in Slicer’s interpreter. However, it’ll be still advisable to do most of the processing in Python CLI modules so that they can run in the background, easily interrupted, etc.


(saima safdar) #30

Hi Andras,
I could no understand white matter analysis extension. is there a simple example for python cli modules. or do you recommend any workshop which can help me to learn how to develop cli extensions within slicer.

regards,
Saima Safdar


(Andras Lasso) #31

A simpler example is PyCLIModule4Test example:

In the executed Python script you can launch an external Python interpreter (Python3, anaconda, etc.), similarly to how it is done here: Subprocess call in Python interpreter results in memory corruption


(saima safdar) #32

Hi Andras,
Is there any video on how to develop cli modules. I have searched for step by step guide but couldnt found. I am unable to establish links between different files. How to run these files?
I have seen videos for how to make scripted modules in slicer and how to use the build in cli modules.
I am unable to understand the connections between files.
When I create a cli module in slicer is gives me .xml and .cxx files. Do i need to create the .py and place it in this folder.
How to run this module in slicer? as with scripted it appears in the modules section but cli do not appear in the modules section.

Please help

Regards,
Saima


(Felipe Cabrera) #33

@lassoan, and about using TensorFlow with Slicer in a Windows 10, is it possible now?
What are the steps that i need to take to make it work?

Thanks


(Andras Lasso) #34

Yes, it works. You can run any Python script in any environment that you have set up on your system as described in my post above.


(David Garcia Mato) #35

Hi Andras,

I would like to use the function scipy.optimize.minimize from scipy.

I have tried to install scipy using pip in Slicer 4.8.1 and 4.10.0, but I am not able to install it properly. I get the following error:

image

I am doing the installation like this:

from pip._internal import main as pipmain
pipmain([‘install’,‘scipy’])

Is there any way I can use scipy.optimize.minimize function is my 3D Slicer module? What about using this function from a Python CLI module?

Thanks for your time,

Best,

David


(Jean Christophe Fillion Robin) #36

Hi David,

We will shortly distribute scipy along with Slicer, this should happen by the end of the week.

Thanks for your patience,
Jc


(Andras Lasso) #37

This will be great! Is it going to be included in Slicer-4.10.1? If it is not risky/complicated then it probably should.


(David Garcia Mato) #38

That’s great JC! Thanks for the info!

I will check it at the end of the week. It would be great if it was included in the nightly build or the stable version.


(David Garcia Mato) #39

Hi JC,

Is Scipy already available?

Thanks!

David


(Jean Christophe Fillion Robin) #40

Hi David,

Not yet, I have to tackle a more urgent deadline first. I will resume work on scipy integration afterward.

Jc


(ibr_ex@yahoo.com) #41

In my case, I tried to add scipy via slicer python interactor (as I did with 4.8.1) but it didn’t work. I added scipy to slicer-4.10 by copy/paste scipy folder from 4.8.1 and it works. e.g.

cp -r  Slicer-4.8.1/lib/Python/lib/python2.7/site-packages/scipy   Slicer-4.10.0/lib/Python/lib/python2.7/site-packages

(Andras Lasso) #42

Python binaries are ABI compatible with Slicer’s bundled Python in Linux but not in Windows. If you use Windows, you need to wait for Jc.