昨天费老劲配置好了python 3.7的环境,今天装pyradiomics又遇到了大麻烦。
首先有一点需要搞明白:安装一个包之前要先激活适配的环境,比如装pyradiomics就要先在anaconda里激活3.7的环境。anaconda默认搭配的编译器是Spyder,感觉与Rstudio界面比较相似,对熟悉R语言的同学来说可能比jupyter更容易上手。顺便吐槽一下,上解螺旋的课跟没上一样,最后还是得自己查资料问熟人。
今天安装pyradiomics,一开始是直接在powershell里敲的:
pip install pyradiomics
但是安装完了之后在Spyder里导入不了radiomics包
去官网看了一下发现人家的安装代码是这么写的:
conda install -c radiomics pyradiomics
但是重新去安装的时候报错了,报错内容是:
ProxyError: Conda cannot proceed due to an error in your proxy configuration.
Check for typos and other configuration errors in any '.netrc' file in your home directory,
any environment variables ending in '_PROXY', and any other system-wide proxy
configuration settings.
赶紧把VPN关了,还是不管用。下一步去搜了一下,有网友表示要在网络设置里修改一下
如图
然后重新再安装就完成了
但即便是这样依然不能正常运行pyradiomics的示例代码
import radiomics
Traceback (most recent call last):
Input In [9] in <cell line: 1>
import radiomics
ModuleNotFoundError: No module named 'radiomics'
检查一下Spyder右下角的environment,发现环境不对,重新设置一下,然后重启Spyder,这次在控制台提示了新的报错:
Your Python environment or installation doesn't have the spyder‑kernels module or the right version of it installed (>= 2.1.0 and < 2.2.0). Without this module is not possible for Spyder to create a console for you.
按照提示关闭Spyder并安装这个包
conda install spyder-kernels=2.1
要注意这段代码不能直接复制到conda里,“-”复制过去会变成“?”,得手动改一下。然后等装完再试一下
IPython -- An enhanced Interactive Python.
from __future__ import print_function
import six
import os # needed navigate the system to get the input data
import radiomics
from radiomics import featureextractor # This module is used for interaction with pyradiomics
这下好了
网友评论