Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4066890
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:10:57+00:00 2026-05-20T16:10:57+00:00

I have defined the name of my wrapper object in my c file blargUtils.c

  • 0

I have defined the name of my wrapper object in my c file blargUtils.c like this (I have defined methods and the lot for it in Blargmethods)…

void initBlarg(){
    Py_InitModule("Blarg", Blargmethods);
}

I compiled it like so…

blarglib: blargUtils.c
    gcc -I/usr/include/python2.6 -fPIC -c blargUtils.c -Wall    
    gcc -shared blargUtils.o -o blargUtils.so
clean:  
    rm *.so

However, when I try to import the wrapper in my python script…

import Blarg

Its says it says: “ImportError: No module named Blarg”. I’m a little lost here and I don’t understand why it cannot find the class when they are the exact same spelling. Maybe its a logic error?

If more code is needed let me know.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T16:10:58+00:00Added an answer on May 20, 2026 at 4:10 pm

    First of all, from looking at the comments, I see that renaming it didn’t work. This means (1) python can’t find the .so file, (2) the .so file isn’t usable (i.e. not compiled correctly or not all required symbols are found), or (3) there is a .py/.pyc/.pyo file in the same directory which already has that name. If you have Blarg.py already defined, python will look at this file first. The same goes if you have a directory named Blarg in your search path. So instead of bashing your head against the wall, try this:

    1) Rename your .so library to something guaranteed not to collide (i.e. _Blarg)

    void initBlarg() {
        Py_InitModule("_Blarg", Blargmethods);
    }
    

    2) Compile it with the SAME NAME

    gcc -I/usr/include/python2.6 -fPIC -c blargUtils.c -Wall    
    gcc -shared blargUtils.o -Wl,-soname -Wl,_Blarg.so -o _Blarg.so
    

    3) Create a python wrapper (i.e. Blarg.py)

    import sys
    sys.path.append('/path/to/your/library')
    
    import _Blarg
    
    def blargFunc1(*args):
        """Wrap blargFunc1"""
        return _Blarg.blargFunc1(*args)
    

    4) Now just use it as normal

    import Blarg
    Blarg.blargFunc1(1, 2, 3)
    

    Obviously this is a bit of overkill, but it should help you determine where the problem is. Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a using statement defined like this in codebehind: using Name = Extremely.Long.And.Unwieldy.Namespace
I have the following object defined function BusinessUnit(id, name, code) { this.id = ko.observable(id);
Say I have a model object 'Person' defined, which has a field called 'Name'.
I have a Factory like this: FactoryGirl.define do factory :subject do name 'Calculus' end
Situation: I have a wrapper panel UserControl like this (namespaces and visual details removed
I have defined 2 event listeners for name: kernel.event_listener, event: kernel.request, but I can
I have defined a struct ABC to contain an int ID, string NAME, string
I have an entity defined as follows @Entity(name = Report) @Table(name = REPORTS) @org.hibernate.annotations.Entity(dynamicInsert
I have a struct defined as: struct { char name[32]; int size; int start;
I have an adjacency_list graph defined as follows: struct VertexProperties{ std::string name; ... };

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.