This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Embedding python in a shared library fails to import the Python module
Type: behavior Stage: resolved
Components: Build Versions: Python 3.4
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: iritkatriel, suzaku
Priority: normal Keywords:

Created on 2016-08-31 19:35 by suzaku, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pystack.c suzaku, 2016-08-31 19:35
Messages (4)
msg274062 - (view) Author: Xyzzy (suzaku) Date: 2016-08-31 19:35
I am having the same error as described by https://bugs.python.org/issue19153 and http://bugs.python.org/issue4434. My shared library is unable to import the Python module I created. I am attaching my C file which calls the python function Rough.py, whose code is written as under:
import math
def WallRough(*wss):
    size=len(wss)
   
    result=[0 for i in range(size)]
    for i in range(size):
       
        wss_mag=math.sqrt(wss[i][0]*wss[i][0]+wss[i][1]*wss[i][1]+wss[i][2]*wss[i][2])
       
        result[i]=1
    
    return result
msg274063 - (view) Author: Xyzzy (suzaku) Date: 2016-08-31 19:37
I am having the same error as described by https://bugs.python.org/issue19153 and http://bugs.python.org/issue4434. My shared library is unable to import the Python module I created. I am attaching my C file which calls the python function Rough.py, whose code is written as under:
import math
def WallRough(*wss):
    size=len(wss)
   
    result=[0 for i in range(size)]
    for i in range(size):
       
        wss_mag=math.sqrt(wss[i][0]*wss[i][0]+wss[i][1]*wss[i][1]+wss[i][2]*wss[i][2])
       
        result[i]=1
    
    return result

I am using the following for compilation and linking:
gcc -fPIC *.c -I-I/usr/local/include -I/usr/local/include -I/usr/local/include/python3.4m -I/usr/local/include/python3.4m  -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DDOUBLE_PRECISION -L/usr/local/lib  -lpthread -ldl  -lutil -lm -lpython3.4m -Xlinker -export-dynamic /usr/local/lib/libpython3.4m.so /usr/local/lib/libpython3.4m.a -shared -o librough30.so
msg407762 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-12-05 23:56
Did Antoine's fix from issue19153 solve your problem?
msg408378 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-12-12 12:04
3.4 is no longer maintained. Please create a new issue if you are still having this problem on a current python version (>= 3.9).
History
Date User Action Args
2022-04-11 14:58:35adminsetgithub: 72107
2021-12-12 12:04:32iritkatrielsetstatus: pending -> closed
resolution: out of date
messages: + msg408378

stage: resolved
2021-12-05 23:57:06iritkatrielsetstatus: open -> pending
2021-12-05 23:56:48iritkatrielsetnosy: + iritkatriel
messages: + msg407762
2016-08-31 19:37:41suzakusetmessages: + msg274063
2016-08-31 19:35:50suzakucreate