Python Forum
Please help me!! Can't get rid of error message in Python.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please help me!! Can't get rid of error message in Python.
#1
Hi! I have a question about Ctypes. 
I'm attempting to build a small object to pass around between fortran code and Python. But I find an error, which I show below.

Thank you in advance.

Grasshopper Python Script Editor

from ctypes import *
#call fortran code below.
mylib = CDLL('C:\\Users\\Owner\\sub.array.fortran.dll')

mylib.mySub.argtypes = [ POINTER(c_double), c_int, POINTER(c_double) ]
mylib.mySub.restype = c_void_p
ArrayType = c_double*5
IntType = c_int
input1 = ArrayType(1.1,2.2,3.3,4.4,5.5)
input2 = 5
inputoutput = ArrayType()

mylib.mySub( input1, input2, inputoutput )

print '------------------------------------------------------' 
print 'output within Python'
a = [0,1,2,3,4]
for ii in a: print inputoutput[ii]
Reply
#2
Quote:But I find an error, which I show below.

Looking for above (full traceback please)
Reply
#3
Hi! Larz60+
Thank you for the information. I'm sorry I didn't make it clear enough.
Now I am using IronPython. This is a little different from Python. I have heard that in IronPython we can not use Numpy.

I'm working through a uni project in which I'm trying to use Fortran code cause I already have a tons of sources. For GUI ,Graphical User Interface, I need to use IronPython and Ctypes.

Unfortunately, I can not show you all sources cause it is really long.
What I know now is that "mylib.mySub( input1, input2, inputoutput )"is wrong. But I do not know what I need to do.

This is link.
http://stackoverflow.com/questions/15875...ith-python

I checked that my code run on Python. But I can not compile thin in IronPython.

Thanks in advance for any advice!
Reply
#4
You don't actually show your error anywhere. Also, you should provide a snippet of Python code which is runnable, reproduces the problem, and is as short as possible. 10-20 lines is typical, though honestly 20 lines is usually far more than enough once the code is simplified to just reproduce the problem.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python code tp determin a userName and print message jackAmin 4 1,796 Nov-20-2022, 12:03 AM
Last Post: rob101
  Creating Email Message Class in Python QuavoJ 1 2,139 Jul-20-2020, 08:30 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020