Slicer学习笔记(十八)添加一个python扩展模块
1、添加一个开发好的模块
如果A已经开发好一个扩展模块test,B要加载A开发的扩展模块。 跟 Slicer学习笔记(十七)编写一个python扩展模块中的前2步一样,第3步选择“Select Extension”,然后指定目录到扩展模块的目录。
2、模块加载失败原因查看
如果模块加载失败,可以从 View --> Error Log中去查看加载失败的原因。 比如查看到加载失败的原因是:
ModuleNotFoundError: No module named 'pandas'
那么就需要在slicer的环境中安装缺少的模块。
3、安装缺少的模块
在slicer的python Interactor中执行下面的命令安装:
pip_install("pandas")
然后就会把缺少的模块安装上:
>>> pip_install("pandas")
Collecting pandas
Downloading pandas-1.1.5-cp36-cp36m-win_amd64.whl (8.7 MB)
Requirement already satisfied: numpy>=1.15.4 in c:\programdata\na-mic\slicer 4.11.20210226\lib\python\lib\site-packages (from pandas) (1.19.2)
Collecting python-dateutil>=2.7.3
Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Requirement already satisfied: six>=1.5 in c:\programdata\na-mic\slicer 4.11.20210226\lib\python\lib\site-packages (from python-dateutil>=2.7.3->pandas) (1.15.0)
Collecting pytz>=2017.2
Downloading pytz-2021.1-py2.py3-none-any.whl (510 kB)
Installing collected packages: pytz, python-dateutil, pandas
Successfully installed pandas-1.1.5 python-dateutil-2.8.2 pytz-2021.1
WARNING: You are using pip version 20.3.3; however, version 21.2.4 is available.
You should consider upgrading via the 'C:\ProgramData\NA-MIC\Slicer 4.11.20210226\bin\python-real.exe -m pip install --upgrade pip' command.
|