Skip to content

[doc] Embedding into a shared library fails again #63352

Open

Description

@rinatous
mannequin
BPO 19153
Nosy @doko42, @pitrou, @sandrotosi

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2013-10-03.16:36:53.114>
labels = ['3.11', 'type-bug', '3.9', '3.10', 'docs']
title = '[doc] Embedding into a shared library fails again'
updated_at = <Date 2021-12-05.12:34:31.228>
user = 'https://bugs.python.org/rinatous'

bugs.python.org fields:

activity = <Date 2021-12-05.12:34:31.228>
actor = 'iritkatriel'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2013-10-03.16:36:53.114>
creator = 'rinatous'
dependencies = []
files = []
hgrepos = []
issue_num = 19153
keywords = []
message_count = 4.0
messages = ['198900', '198945', '198961', '198962']
nosy_count = 5.0
nosy_names = ['doko', 'pitrou', 'sandro.tosi', 'docs@python', 'rinatous']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue19153'
versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

Activity

  1. rinatous commented on Oct 3, 2013

    rinatousmannequin
    MannequinAuthor

    I have same error as here described http://bugs.python.org/issue4434

    I made everythings according this article http://docs.python.org/2/extending/embedding.html#compiling-and-linking-under-unix-like-systems and more but when i try to call interpriter from C++ it fails with errors

    python_support::pre_process_payment() failed
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "<hidden-path>/payments/__init__.py", line 1, in <module>
        from .factory import *
      File "<hidden-path>/payments/factory.py", line 7, in <module>
        import psycopg2
      File "/usr/local/lib/python2.7/dist-packages/psycopg2/__init__.py", line 50, in <module>
        from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
    ImportError: /usr/local/lib/python2.7/dist-packages/psycopg2/_psycopg.so: undefined symbol: PyExc_SystemError
    Error in sys.excepthook:
    Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 66, in apport_excepthook
        from apport.fileutils import likely_packaged, get_recent_crashes
      File "/usr/lib/python2.7/dist-packages/apport/__init__.py", line 1, in <module>
        from apport.report import Report
      File "/usr/lib/python2.7/dist-packages/apport/report.py", line 16, in <module>
        from xml.parsers.expat import ExpatError
      File "/usr/lib/python2.7/xml/parsers/expat.py", line 4, in <module>
        from pyexpat import *
    ImportError: /usr/lib/python2.7/lib-dynload/pyexpat.so: undefined symbol: _Py_ZeroStruct
    
    Original exception was:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "<hidden-path>/payments/__init__.py", line 1, in <module>
        from .factory import *
      File "<hidden-path>/payments/factory.py", line 7, in <module>
        import psycopg2
      File "/usr/local/lib/python2.7/dist-packages/psycopg2/__init__.py", line 50, in <module>
        from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
    ImportError: /usr/local/lib/python2.7/dist-packages/psycopg2/_psycopg.so: undefined symbol: PyExc_SystemError

    Environment
    3.2.0-54-generic-pae #82-Ubuntu (12.04)
    g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
    Boost.Python 1.48
    Python 2.7.3 (default, Sep 26 2013, 20:08:41)
    [GCC 4.6.3] on linux2

    No custom builds. Every package from ubuntu repository. Psycopg2 installed by pip

    Project is big so i can't to provide code

  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    type-bugAn unexpected behavior, bug, or error
    on Oct 3, 2013
  3. pitrou commented on Oct 4, 2013

    @pitrou
    Member

    No custom builds. Every package from ubuntu repository. Psycopg2 installed by pip

    You may have to rebuild packages using the custom Python, not the system Python, since the linker options have to be different (especially the "shared" part: Ubuntu's Python is a static build, not a shared library build).

    Or perhaps you can dlopen the CPython shared library with the RTLD_GLOBAL flag. I don't know.

    I don't know if this is something that we can alleviate in Python itself.

  4. rinatous commented on Oct 4, 2013

    rinatousmannequin
    MannequinAuthor

    Or perhaps you can dlopen the CPython shared library with the RTLD_GLOBAL flag. I don't know.

    Yes, it works. I made it is my shared library before boost block like this

    {
      void* handle = dlopen("libpython2.7.so", RTLD_LAZY | RTLD_GLOBAL);
      // boost wrapper for python call
      dlclose(handle);
    }

    I think if nothing helps, i'll put this code into __attribute__((ctor|dtor)) functions

    Thanks a lot

  5. pitrou commented on Oct 4, 2013

    @pitrou
    Member

    Ok, making it a documentation issue in case it deserves clarification in the docs.

  6. added
    docsDocumentation in the Doc dir
    and removed
    stdlibStandard Library Python modules in the Lib/ directory
    on Oct 4, 2013
  7. changed the title [-]Embedding into a shared library fails again[/-] [+][doc] Embedding into a shared library fails again[/+] on Dec 5, 2021
  8. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10 (EOL)end of life3.11only security fixes3.9 (EOL)end of lifedocsDocumentation in the Doc dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions