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

  • Home
  • SEARCH
  • 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 942145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:13:32+00:00 2026-05-15T22:13:32+00:00

I have a program which embeds both python2 and python3 interpreters. The libpython shared

  • 0

I have a program which embeds both python2 and python3 interpreters. The libpython shared libraries are dlopen()ed by the respective commands which provide access to the interpreters and each interpreter maintains its own state.

This all works just fine if the user only uses pure python modules or builtins. Trying to load a C extension (like termios) then complains “undefined symbol: PyExc_TypeError”. This happens because the C extensions aren’t linked against libpython. Python upstream doesn’t think this is a problem.

To get around that, I can change the dlopen() calls in my program for the libpython shared libraries to use RTLD_GLOBAL. As soon as I do that, however, trying to use both the python2 and python3 interpreters in the same session of the program causes it to ABRT in the process of calling Py_Initialize for whichever interpreter was invoked second. Using only one of the interpreters works fine.

Any idea how to get this to work when the C extensions won’t be linked against libpython, therefore requiring the use of RTLD_GLOBAL?

  • 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-15T22:13:33+00:00Added an answer on May 15, 2026 at 10:13 pm

    Sorry, but this won’t work the way you want it to. The solution ordinarily would involve linking each extension to versioned libpython symbols; or one could have a namespace-capable linker, such that one could map each library to a different namespace, rather than a global one. Unfortunately neither of these options are easily applied, so you’re probably stuck with a multi-process model. Simply fork and have one process link to each version of Python. The tough bit then is how to share whatever data led you to require two distinct Python interpreters in the first place. Perhaps a description of what problem led to the question may help find a better solution?

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

Sidebar

Related Questions

I have a program which embeds Python (via Boost.Python), and provides an 'extension' framework.
I have a program which creates JButtons which are then added to a JPanel
I have a program which dynamically generates a GUI. I don't know how many
I have a program which outputs a pair of words surrounded by spaces on
I have a program which prints a multi-page document. The first page is pre-printed
I have a program which I would like to run every X min the
I have a program which runs an external, command line utility and reads the
I have a program which doesn't once reference System.I0, coded in vb.net, yet for
I have a program which takes a long time to complete. I would like
I have a program which runs on a console and its Umlauts and other

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.