0
當我運行在使用SimpleITK 0.10.0在DCM文件中更新標記的代碼Python 3(https://itk.org/SimpleITKDoxygen010/html/Python_2DicomModifyTags_8py-example.html)代碼按照說明工作。當使用Flask與python 3和SimpleITK 0.10.0在一起,我得到AttributeError:類型對象'對象'沒有屬性'__getattr__'
目前我介紹燒瓶部件中的代碼來創建的API,我得到
AttributeError的:對象類型「對象」有沒有屬性「__getattr__」
錯誤。我已經使用的代碼如下
from __future__ import print_function
import SimpleITK
from flask import Flask
import time
app = Flask(__name__)
@app.route('/fuse')
def fuse():
image = SimpleITK.ReadImage("CT/IMG-0002-000001.dcm")
mean_image = SimpleITK.BoxMean(image, [3,3,1])
all_keys = image.GetMetaDataKeys()
for key in all_keys:
mean_image.SetMetaData(key, image.GetMetaData(key))
mean_image.SetMetaData("0008|0008", "DERIVED\SECONDARY")
modification_time = time.strftime("%H%M%S")
modification_date = time.strftime("%Y%m%d")
mean_image.SetMetaData("0008|0031", modification_time)
mean_image.SetMetaData("0008|0021", modification_date)
print(mean_image.GetMetaData("0008|0031"))
return "finish"
錯誤我得到低於
[2016-10-05 14:47:05,816] ERROR in app: Exception on /fuse [GET]
Traceback (most recent call last):
File "c:\python27\lib\site-packages\flask\app.py", line 1988, in wsgi_app
response = self.full_dispatch_request()
File "c:\python27\lib\site-packages\flask\app.py", line 1641, in full_dispatch_request
rv = self.handle_user_exception(e)
File "c:\python27\lib\site-packages\flask\app.py", line 1544, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "c:\python27\lib\site-packages\flask\app.py", line 1639, in full_dispatch_request
rv = self.dispatch_request()
File "c:\python27\lib\site-packages\flask\app.py", line 1625, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "E:\ITK_EXP_10\exp2.py", line 24, in fuse
keyable(mean_image, image, key)
File "E:\ITK_EXP_10\exp2.py", line 12, in keyable
mean_image.SetMetaData(key, image.GetMetaData(key))
File "c:\python27\lib\site-packages\SimpleITK\SimpleITK.py", line 3579, in <lambda>
__getattr__ = lambda self, name: _swig_getattr(self, Image, name)
File "c:\python27\lib\site-packages\SimpleITK\SimpleITK.py", line 74, in _swig_getattr
return _swig_getattr_nondynamic(self, class_type, name, 0)
File "c:\python27\lib\site-packages\SimpleITK\SimpleITK.py", line 69, in _swig_getattr_nondynamic
return object.__getattr__(self, name)
AttributeError: type object 'object' has no attribute '__getattr__'
127.0.0.1 - - [05/Oct/2016 14:47:05] "GET /fuse HTTP/1.1" 500 -
127.0.0.1 - - [05/Oct/2016 14:47:05] "GET /favicon.ico HTTP/1.1" 404 -
我在巨蟒編碼初學者,實際上初學編碼本身,可以有一個人請幫我解決這個問題,還是幫我理解這個問題,以便我可以修復它?
在此先感謝