Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'output': 0.05; 'error:': 0.07; 'importerror:': 0.07; 'odd': 0.07; 'paths': 0.07; 'sys': 0.07; '#include': 0.09; 'testing,': 0.09; 'variables.': 0.09; 'wrong,': 0.09; 'python': 0.11; 'bug': 0.12; '2.7': 0.14; '(same': 0.16; '(setting': 0.16; 'before.': 0.16; 'codec': 0.16; 'interpreter,': 0.16; 'path.': 0.16; 'path:': 0.16; 'prefix:': 0.16; 'received:fi': 0.16; 'stumbled': 0.16; 'weird': 0.16; 'module': 0.19; 'dependent': 0.19; '>>>': 0.22; 'import': 0.22; 'installation': 0.23; 'load': 0.23; 'error': 0.23; 'char': 0.24; 'environment': 0.24; 'correct': 0.29; 'getting': 0.31; 'libraries': 0.31; 'file': 0.32; 'supposed': 0.32; 'worked': 0.33; 'could': 0.34; 'problem': 0.35; 'something': 0.35; 'there': 0.35; 'doing': 0.36; 'hi,': 0.36; 'changing': 0.37; 'received:10': 0.37; 'being': 0.38; '8bit%:4': 0.38; 'to:addr:python-list': 0.38; 'skip:- 10': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'unable': 0.39; 'skip:p 20': 0.39; 'full': 0.61; 'header:Message- Id:1': 0.63; 'kind': 0.63; 'charset:windows-1252': 0.65; 'received:130': 0.73; 'behavior': 0.77; '3.4': 0.84; 'const': 0.84; 'haven\x92t': 0.84; 'touched': 0.84 X-Virus-Scanned: amavisd-new at cc.jyu.fi From: Marko Havu Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Py_SetProgramName() and prefixes Date: Thu, 28 Aug 2014 12:58:25 +0300 To: python-list@python.org Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) X-Mailer: Apple Mail (2.1878.6) X-Mailman-Approved-At: Thu, 28 Aug 2014 11:59:08 +0200 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 58 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1409219949 news.xs4all.nl 2840 [2001:888:2000:d::a6]:60730 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:77197 Hi, I have a problem with Py_Initialize() not being able to find python in = the path. Unless I use Py_SetProgramName() with the full path of the = python interpreter, I get the following error message: Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] Fatal Python error: Py_Initialize: unable to load the file system codec ImportError: No module named =92encodings=92 Is there a way of getting this to work without setting $PYTHONHOME? I am = sure this worked for me before. The odd part is, I haven=92t touched my = python installation or environment variables. While doing some testing, = I stumbled across some weird behavior on Python 3.3 and 3.4: = Py_GetPrefix(), Py_GetPath() and other functions that return paths that = are supposed to be set by Py_SetProgramName() all return just =94/=94: ---------------- main.c ---------------- #include #include #include int main(int argc, const char * argv[]) { printf("path: %s\n", getenv("PATH")); Py_SetProgramName(L"/anaconda/envs/python3.4/bin/python"); Py_Initialize(); wprintf(L"prefix: %s\n", Py_GetPrefix()); PyRun_InteractiveLoop(stdin, ""); Py_Finalize(); return EXIT_SUCCESS; } ---------------- Python 3.4 output (same with 3.3): path: /anaconda/envs/python3.4/bin:/usr/bin:/bin:/usr/sbin:/sbin prefix: / >>> import sys >>> sys.prefix '/anaconda/envs/python3.4' Python 2.7 output (setting correct path and changing char strings to = wchar_t strings): path: /anaconda/envs/python2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin prefix: /anaconda/envs/python2.7 >>> import sys >>> sys.prefix '/anaconda/envs/python2.7=92 Am I doing something wrong, or is this a bug in Python 3? Kind regards, Marko Havu=