Issue 13168: Python 2.6 having trouble finding modules when invoked via a symlink (original) (raw)
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--