Problems with new module in Python (x,y) 2.7

北慕城南 提交于 2019-12-24 19:23:48

问题


I'm trying to use Python(x,y) version 2.7 to deal with some compressed DICOM data. I've installed the mudicom module using pip install and that worked fine. However, I also need the gdcm 2.6 module and I had to jump some hoops to install that using its .exe file and get it added to my PATH.

I then added gdcm.py and gdcmswig.py to my site packages folder and added _gdcmswig.pyd to my DLLs folder as per instructions on another forum I found.

Now Python at least seems to see that I have gdcm, but it's telling me gdcmswig is full of syntax errors, so I'm sure I've done something else wrong.

The only line of code I'm running is

import mudicom

but I'm getting this error:

   runfile('C:/Users/shann/Desktop/CT Processing Tests/Test2.py', wdir='C:/Users/shann/Desktop/CT Processing Tests')
  File "C:\Python27\lib\site-packages\gdcmswig.py", line 116
    def value(self) -> "PyObject *":
                    ^
SyntaxError: invalid syntax

When I click on that line number, it pulls up this section of code:

class SwigPyIterator(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, SwigPyIterator, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, SwigPyIterator, name)

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined - class is abstract")
    __repr__ = _swig_repr
    __swig_destroy__ = _gdcmswig.delete_SwigPyIterator
    __del__ = lambda self: None

    def value(self) -> "PyObject *":
        return _gdcmswig.SwigPyIterator_value(self)

    def incr(self, n: 'size_t'=1) -> "swig::SwigPyIterator *":
        return _gdcmswig.SwigPyIterator_incr(self, n)

    def decr(self, n: 'size_t'=1) -> "swig::SwigPyIterator *":
        return _gdcmswig.SwigPyIterator_decr(self, n)

    def distance(self, x: 'SwigPyIterator') -> "ptrdiff_t":
        return _gdcmswig.SwigPyIterator_distance(self, x)

    def equal(self, x: 'SwigPyIterator') -> "bool":
        return _gdcmswig.SwigPyIterator_equal(self, x)

    def copy(self) -> "swig::SwigPyIterator *":
        return _gdcmswig.SwigPyIterator_copy(self)

    def next(self) -> "PyObject *":
        return _gdcmswig.SwigPyIterator_next(self)

    def __next__(self) -> "PyObject *":
        return _gdcmswig.SwigPyIterator___next__(self)

I tried commenting out the particular line mentioned in the error, but then I got another error saying the next line (def incr...) had a syntax error at the "n:", so I can only assume that would continue through the rest of that class.

Any help would be SO appreciated! I've been struggling to get all this to work for two or three days now.

Thank you!

来源:https://stackoverflow.com/questions/44749471/problems-with-new-module-in-python-x-y-2-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!