anthonyjsmith / pIDLy

pIDLy: IDL within Python
Other
33 stars 14 forks source link

Error using pIDLy on Windows #6

Closed lorenzobernardi closed 7 years ago

lorenzobernardi commented 8 years ago

Hi all, I'm trying to execute the following simple python script:

import pidly
print(pidly.__version__)

I have the following problem:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "E:\Sviluppo\PyCharm Community Edition 4.5.4\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Python34\lib\site-packages\pidly.py", line 88, in <module>
    class IDL(pexpect.spawn):
AttributeError: 'module' object has no attribute 'spawn'

I have already correctly installed pidly and pexpect modules with the command: pip install pidly pexpect and my working environment is:

How can i solve this problem? Thank you for any suggestion. Lorenzo

andreas-schreiber commented 8 years ago

As far as I see, pexpect is not meant to be used under windows with full compatibility. See https://pexpect.readthedocs.org/en/stable/overview.html#windows

Pexpect on Windows New in version 4.0: Windows support

Pexpect can be used on Windows to wait for a pattern to be produced by a child process, using pexpect.popen_spawn.PopenSpawn, or a file descriptor, using pexpect.fdpexpect.fdspawn. This should be considered experimental for now.

pexpect.spawn and pexpect.run() are not available on Windows, as they rely on Unix pseudoterminals (ptys). Cross platform code must not use these.

lorenzobernardi commented 8 years ago

Thank you. Any solutions? Can i solve using some unix emulater, like git bash or other?

andreas-schreiber commented 8 years ago

You should ask the pexpect experts, but would not expect this to be solvable easily. I use therefore a VM with Linux inside, since Windows never was a good choice for doing using science tools.

anthonyjsmith commented 8 years ago

Thanks for the contributions! I'm not using IDL or Python these days, but (1) happy to receive contributions to the code, and (2) it seems that there is a built-in IDL/Python bridge these days, which seems to support Windows: http://www.exelisvis.com/docs/Python.html. Just discovered that today: anyone used it?

andreas-schreiber commented 8 years ago

Thanks, will try it next time needed.

lorenzobernardi commented 8 years ago

Dear all, my aim is to use the script written in IDL, in python:

IDL code:

PRO PS_GS
; Start the application
e = ENVI()
;Generate the roi from a vector file
; Open a vector file
file_vec = Filepath('Sic_Trapani.shp', ROOT_DIR = 'E:\mydirectory\')
vettore = e.OpenVector(file_vec)
; Get the task from the catalog of ENVITasks
Task_VtoR = ENVITask('VectorRecordsToROI')
; Define inputs
Task_VtoR.INPUT_VECTOR = vettore
; Define outputs
Task_VtoR.OUTPUT_ROI_URI = Filepath('roi_roi.xml', ROOT_DIR = 'E:\mydirectory\')
;Run the task
Task_VtoR.Execute
END

The above code works correctly.

I'm trying with the simple following code:

from idlpy import IDL
import numpy.random as ran
e = IDL.ENVI()
#Generate the roi from a vector file
# Open a vector file
file_vec = IDL.Filepath('Sic_Trapani.shp', ROOT_DIR = """E:\\mydirectory\\shp\\""")
vettore = e.OpenVector(file_vec)
#Get the task from the catalog of ENVITasks
Task_VtoR = IDL.ENVITask('VectorRecordsToROI')
#Define inputs
IDL.Task_VtoR.INPUT_VECTOR = vettore
#Define outputs
Task_VtoR.OUTPUT_ROI_URI = IDL.Filepath('roi_roi.xml', ROOT_DIR = """E:\\mydirectory\\""")
#Run the task
IDL.Task_VtoR.Execute

I have several doubts about the:

e=IDL.ENVI()
vettore = e.OpenVector(file_vec)

lines and the IDL.Task using sintax. Perhaps it would be better to use the python library to read the raster and the vector file and to extract the numeric information to be passed to the IDL.Task functions. Any suggestions? I will inform you about future developments or solutions.

Lorenzo

loreberna@gmail.com

lorenzobernardi commented 8 years ago

Update:

I have tryed:

IDL.ENVI()
vector=IDL.ENVI().OpenVector(file_vec)

The result is the following error message:

Impossible find the access point ??0LTISceneBuffer@LizardTech@@QEAA@AEBVLTIPixel@1@IIPEAPEAX@Z into the dynamic link library lti_DSDK.dll

Like arab for me!! I googled the error and i found this site: Malware scan of envi_gdal.dll. Any suggestion? Thanks

anthonyjsmith commented 8 years ago

Not sure this is related to pidly any more... try posting on stackoverflow?

lorenzobernardi commented 8 years ago

i did. No answer. it is a problem related to working with python and idl, but you are right. Thank you

anthonyjsmith commented 7 years ago

I'm going to close this... re-open if appropriate!