This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Python 2.6 having trouble finding modules when invoked via a symlink
Type: compile error Stage:
Components: Interpreter Core Versions: Python 2.6
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: RandyGalbraith, terry.reedy
Priority: normal Keywords:

Created on 2011-10-13 16:08 by RandyGalbraith, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg145468 - (view) Author: Randy Galbraith (RandyGalbraith) Date: 2011-10-13 16:08
Hi Python Developers,

Our install of Python 2.6.4 on AIX 5.3 seems to have problems finding modules
when invoked via a symlink.  A direct path to the binary will work.  One symlink
will work, but another will not.  I created a test harness to demonstrate this
issue and collect (hopefully) useful output.

Regards,
-Randy Galbraith
ps. Thanks for making such a great tool available!

--test script--
#!/bin/sh

ACTUAL_BINARY=/mypath/tool/Python-2.6.4/powerpc-AIX5.3/bin/python
FIRST_SYMLINK=/mypath/tool/bin/python
SECOND_SYMLINK=/mypath/tool/powerpc-AIX5.3/bin/python

set -x
echo
echo "Actual binary..."
ls -ld $ACTUAL_BINARY

echo
echo "First symlink..."
ls -ld $FIRST_SYMLINK

echo
echo "Second symlink..."
ls -ld $SECOND_SYMLINK

echo
echo "Run with actual binary is good..."
$ACTUAL_BINARY -m py_compile test.py

echo
echo "Run with first symlink is bad..."
$FIRST_SYMLINK -m py_compile test.py

echo
echo "Run with second symlink is good..."
$SECOND_SYMLINK  -m py_compile test.py

set +x
echo
echo "Analysis..."
truss $ACTUAL_BINARY -m py_compile test.py 2>truss_binary.log

truss $FIRST_SYMLINK -m py_compile test.py 2>truss_symlink1.log

truss $SECOND_SYMLINK  -m py_compile test.py 2>truss_symlink2.log

echo
echo "runpy is found..."
grep runpy truss_binary.log

echo
echo "runpy is not found..."
grep runpy truss_symlink1.log

echo
echo "runpy is found..."
grep runpy truss_symlink2.log
--end test script--

--terminal output--
$ ./test_script.sh
+ echo

+ echo Actual binary...
Actual binary...
+ ls -ld /mypath/tool/Python-2.6.4/powerpc-AIX5.3/bin/python
-rwxr-xr-x 2 myuserid mygroup1 9727885 2010-02-25 10:57 /mypath/tool/Python-2.6.4/powerpc-AIX5.3/bin/python
+ echo

+ echo First symlink...
First symlink...
+ ls -ld /mypath/tool/bin/python
lrwxrwxrwx 1 myuserid mygroup2 44 2010-06-02 17:16 /mypath/tool/bin/python -> ../../Python-2.6.4/powerpc-AIX5.3/bin/python
+ echo

+ echo Second symlink...
Second symlink...
+ ls -ld /mypath/tool/powerpc-AIX5.3/bin/python
lrwxrwxrwx 1 myuserid mygroup2 44 2010-06-02 17:16 /mypath/tool/powerpc-AIX5.3/bin/python -> ../../Python-2.6.4/powerpc-AIX5.3/bin/python
+ echo

+ echo Run with actual binary is good...
Run with actual binary is good...
+ /mypath/tool/Python-2.6.4/powerpc-AIX5.3/bin/python -m py_compile test.py
+ echo

+ echo Run with first symlink is bad...
Run with first symlink is bad...
+ /mypath/tool/bin/python -m py_compile test.py
Could not import runpy module
+ echo

+ echo Run with second symlink is good...
Run with second symlink is good...
+ /mypath/tool/powerpc-AIX5.3/bin/python -m py_compile test.py

Analysis...

runpy is found...
statx("runpy", 0x2FF21168, 76, 0)		Err#2  ENOENT
open("runpy.so", O_RDONLY)			Err#2  ENOENT
open("runpymodule.so", O_RDONLY)		Err#2  ENOENT
open("runpy.py", O_RDONLY)			Err#2  ENOENT
open("runpy.pyc", O_RDONLY)			Err#2  ENOENT
statx("/mypath/tool/Python-2.6.4/lib/python2.6/runpy", 0x2FF21168, 76, 0) Err#2  ENOENT
open("/mypath/tool/Python-2.6.4/lib/python2.6/runpy.so", O_RDONLY) Err#2  ENOENT
open("/mypath/tool/Python-2.6.4/lib/python2.6/runpymodule.so", O_RDONLY) Err#2  ENOENT
open("/mypath/tool/Python-2.6.4/lib/python2.6/runpy.py", O_RDONLY) = 3
open("/mypath/tool/Python-2.6.4/lib/python2.6/runpy.pyc", O_RDONLY) = 4

runpy is not found...
statx("runpy", 0x2FF21188, 76, 0)		Err#2  ENOENT
open("runpy.so", O_RDONLY)			Err#2  ENOENT
open("runpymodule.so", O_RDONLY)		Err#2  ENOENT
open("runpy.py", O_RDONLY)			Err#2  ENOENT
open("runpy.pyc", O_RDONLY)			Err#2  ENOENT
Could not import runpy module

runpy is found...
statx("runpy", 0x2FF21178, 76, 0)		Err#2  ENOENT
open("runpy.so", O_RDONLY)			Err#2  ENOENT
open("runpymodule.so", O_RDONLY)		Err#2  ENOENT
open("runpy.py", O_RDONLY)			Err#2  ENOENT
open("runpy.pyc", O_RDONLY)			Err#2  ENOENT
statx("/mypath/tool/Python-2.6.4/lib/python2.6/runpy", 0x2FF21178, 76, 0) Err#2  ENOENT
open("/mypath/tool/Python-2.6.4/lib/python2.6/runpy.so", O_RDONLY) Err#2  ENOENT
open("/mypath/tool/Python-2.6.4/lib/python2.6/runpymodule.so", O_RDONLY) Err#2  ENOENT
open("/mypath/tool/Python-2.6.4/lib/python2.6/runpy.py", O_RDONLY) = 3
open("/mypath/tool/Python-2.6.4/lib/python2.6/runpy.pyc", O_RDONLY) = 4

--end terminal output--
msg145576 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-10-15 00:34
Try upgrading to 2.6.6, 2.6.7 or 2.7.2. 

In any case, 2.6 is in security-fix only mode, so unless you have a problem with the most recent releases (2.7.2 or 3.2.2) this issue should be closed as out-of-date.
History
Date User Action Args
2022-04-11 14:57:22adminsetgithub: 57377
2012-01-10 03:45:26terry.reedysetstatus: open -> closed
resolution: out of date
2011-10-15 00:34:30terry.reedysetnosy: + terry.reedy
messages: + msg145576
2011-10-13 16:08:53RandyGalbraithcreate