Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #93377

Py_InitializeEx() in CygWin64's Python2.7

Date 2015-07-01 17:44 +0200
From Gisle Vanem <gvanem@yahoo.no>
Subject Py_InitializeEx() in CygWin64's Python2.7
Newsgroups comp.lang.python
Message-ID <mailman.220.1435765587.3674.python-list@python.org> (permalink)

Show all headers | View raw


I've written a C-program that embeds Python 2.7.
It has worked fine for several years using MingW or MSVC. Now I'd like
to support the python2.7.exe that comes with CygWin64.

But it seems to fail inside 'Py_InitializeEx(0)' where it just prints:
   ImportError: No module named site

What? Does really all Pythons needs a 'PYTHONPATH' set to point to the
site.py? Or is it only CygWin that is special here? Since if I do a
"set PYTHONPATH=/usr/lib/python2.7" in my shell, my program works.

These are some of the func-ptr and arguments I use during init:

  Py_SetProgramName ("/cygdrive/f/gv/VC_project/EnvTool/src/envtool.exe")
  Py_SetPythonHome ("/usr/lib/python2.7")
  Py_InitializeEx(0)   << libpython2.7.dll chokes inside here for a mysterious reason.

I maybe naively assumes calling 'Py_SetPythonHome' is doing part of
what parsing the PYTHONPATH should do. But it doesn't seems so.

If I from my cmd-line do a:

c:\> f:\CygWin64\bin\python2.7.exe -c "import sys; print (sys.modules)"

I can see:
   <module 'site' from '/usr/lib/python2.7/site.pyo'>

So what could be the reason it's not able to load and parse it
without a 'PYTHONPATH' set explicit?

-- 
--gv

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Py_InitializeEx() in CygWin64's Python2.7 Gisle Vanem <gvanem@yahoo.no> - 2015-07-01 17:44 +0200

csiph-web