delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/03/04/18:16:54

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:from:subject:cc:message-id:date
:mime-version:content-type:content-transfer-encoding; q=dns; s=
default; b=A5hoJZZB1Zx/HdDWExN2N1uaGxPZphVLMTW1nXlon1GyTVcIc3sUv
JAFMG+zTXQZLWeGY6JeN9DTzkg3VuiKgqZo0/p8aRKeDPT6o2pRoclXT5bR8v37L
NxlXNl8o13hW+Zg+r3eTaHgC/FHpP1r4MjidLV5D5gyFnkgsKWtZz8=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:from:subject:cc:message-id:date
:mime-version:content-type:content-transfer-encoding; s=default;
bh=OOeXSObrZ6faYkrF/IzO1r/1PWQ=; b=ad3K+gPTCoWCfm7Cf+4bIa3pONzy
mpW820lusSvE4wONfYB771X2CtTNjhsizKerrWC//8nicjgsyTsJ4+xdx64oeVPi
FKbdwn/v7B3oUuZqd7/9ubi8jbho0jPLB/dsRyAv2rkVRvO5GUGYAYbFi7Uz7Exi
Xa28/TBt3+LLbhU=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=BAYES_00,FREEMAIL_FROM,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 spammy=UD:cz, Technical, auxiliary, Hx-languages-length:3140
X-HELO: mail-wm0-f45.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:cc:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=OvGUWKTDLUapLJ0SUpJt0wyNnM3BucoMbuCh14OV/rw=; b=NzpIHlNfiSa4eB9NfPHu3CsmeN2k6X+VKIYSuNJSvCoAkddPoR5I4RwCL2biBe9UFN TnzNF3OYYS6Be+ML8j5FmD6NVXfnk0CBqQrRduiLfJidIhE+V9kGS//fdvwKLk6D9NOO LuSbvinWRNYxLZhSiweGjJhHvoy9rNAOC77u4KoQd8S63gHvDZja2MUnfPO77qNoXcnR ysDLzAwX1n+JL5UveSVBSyaC+YYcYbek0JUtPIuIw8klQcV/hfacgxjdPuzasrOzZ7Be xeFbI+mt6JLga2ZWUlhypVugdj+FtpVVlV9PrQHjJ+5PXyeIRJfLnunJsMO0xh5zBvrK 8KRQ==
X-Gm-Message-State: AD7BkJL6UAic8WrN/52stkXQv7po5jeTQebLLz9poejYdEVC7t0P3JeGKMPYsnluyT/0/g==
X-Received: by 10.194.83.42 with SMTP id n10mr11555758wjy.20.1457133387188; Fri, 04 Mar 2016 15:16:27 -0800 (PST)
To: cygwin AT cygwin DOT com
From: Jan Brezina <jbrezmorf AT gmail DOT com>
Subject: python: problem loading module in DLL
X-Enigmail-Draft-Status: N1110
Cc: =?UTF-8?B?SmFuIEh5YsWh?= <jan DOT hybs AT tul DOT cz>
Message-ID: <56DA1747.3090803@gmail.com>
Date: Sat, 5 Mar 2016 00:16:23 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0
MIME-Version: 1.0

Hi,

we are developing a multiplatform application using C++ with the
embedded Python. The problem is that the import of the module 'binascii'
(located in python2.7/lib-dynload/binascii.dll)
fails when the C++ application (which eventually call the embedded
python script) is called from the Windows cmd. Resulting error message is:

'ImportError: No such file or directory\n'

However, the import works when the C++ application is called from the
cygwin shell. Import of other module, in particular 'time' (located in
python2.7/lib-dynload/time.dll), works in both cases. In fact it seems
that the python found the binascii.dll, but was unable to load it
somehow. If we create an auxiliary python2.7/lib-dynload/binascii.py
we get the same error, so we guess that the importer found binascii.dll
first but fail to load it and doesn't continue to find also binascii.py.

The behavior is similar to the issue
https://www.cygwin.com/ml/cygwin/2013-04/msg00408.html. We tried to
reinstall zlib and related packages without success.

From our point of view it is a bug, but possibly such usage of the
embedded Python is unsupported and we were just lucky until now using
the modules that works only by chance.
Anyway if it is not a bug, can anybody provide some hint what is the
mechanism of loading DLL python modules and how to investigate the real
problem (hidden by the generic error message).

The code to reproduce the problem is on github:
https://github.com/x3mSpeedy/cygwin-python-issue

and also pasted at the end.

thank you for any help.

Jan Brezina and Jan Hybs


Cygwin version:
$ uname -a
CYGWIN_NT-6.1 Flow123d 2.4.1(0.293/5/3) 2016-01-24 11:26 x86_64 Cygwin

Windows version is:
Windows 7

Bug occures in both python2.7 and python3.4 version:
$ python2.7 --version
Python 2.7.10

$ python3.4 --version
Python 3.4.3

C++ code to reproduce the error:
-----------------------------------------------------------------------
#include <Python.h>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[]) {
  Py_Initialize();
  cout << "Python path: " << (Py_GetPath()) << endl;
  cout << "Python prefix: " << (Py_GetPrefix()) << endl;
  cout << "Python exec prefix: " << (Py_GetExecPrefix()) << endl;
  cout << "------------------" << endl;
  cout << "Python version" << endl;
  PyRun_SimpleString("\nimport sys; print (sys.version_info)");
  cout << "------------------" << endl;
  cout << "Test: time module" << endl;
  PyRun_SimpleString("\nimport time as mod; print (mod, mod.__file__)"
                     "\nfor x in dir(mod):\n"
                     "\n  print ('{:20s}{}'.format(x, str(getattr(mod,
x, ''))[0:35]))"
                     );
  cout << "------------------" << endl;
  cout << "Test: binascii module" << endl;
  PyRun_SimpleString("\nimport binascii as mod; print (mod, mod.__file__)"
                     "\nfor x in dir(mod):\n"
                     "\n  print ('{:20s}{}'.format(x, str(getattr(mod,
x, ''))[0:35]))"
                     );
  Py_Finalize();
  return 0;
}
------------------------------------------------------------



-- 
------------------------
Mgr. Jan Brezina, Ph. D.
Technical University in Liberec, New technologies institute
http://www.nti.tul.cz/cz/WikiUser:Jan.Brezina

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019