Issue
The is the link to the python package I am trying to compile and install. I have tried what I can find online for hours but cannot get over the ImportError
.
The package has the following contents.
Its setup.py has the following content. There are two modules here. One is the python wrapper package with sparse_learning
, the other is a c extension module named proj_module
.
I followed the procedure described here https://docs.python.org/3.6/extending/building.html to compile and install on Ubuntu 18.04. There is no error message.
sudo python3 setup.py build_ext --inplace
sudo python3 setup.py install
Then when I try to load the C-extension module proj_module
, an error "ImportError: dynamic module does not define module export function" occurs.
python3 -c "import proj_module"
I tried to apply solutions found online, including uninstalling Python2 with sudo apt purge python2.7-minimal
, or add python3 site-packages paths to the bashrc. However, none of them worked.
I just know it was originally written for Python 2. Then two modifications are made in the main_wrapper.c
for it to run for Python 3. They look correct to me...
Solution
It looks like you've got a little bit of Python 2-style code mixed in with your Python 3 module here. You just need to replace
PyMODINIT_FUNC initproj_module() {
with
PyMODINIT_FUNC PyInit_proj_module() {
in your main_wrapper.c
file.
Answered By - Nathan VÄ“rzemnieks
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.