importing site fails - why?

H

Helmut Jarausch

Hi,

as often before, I've cloned a working system (GenToo) onto another
machine. There, from a livecd and chroot to the cloned root partition

python -v
import site

fails with the following error
Python 2.6.6 (r266:84292, Oct 13 2010, 09:06:24)
[GCC 4.4.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
dlopen("/usr/lib64/python2.6/lib-dynload/readline.so", 2);
import readline # dynamically loaded from /usr/lib64/python2.6/lib-
dynload/readline.so# /usr/lib64/python2.6/site.pyc matches /usr/lib64/python2.6/site.py
import site # precompiled from /usr/lib64/python2.6/site.pyc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.6/site.py", line 526, in <module>
main()
File "/usr/lib64/python2.6/site.py", line 509, in main
known_paths = addsitepackages(known_paths)
File "/usr/lib64/python2.6/site.py", line 289, in addsitepackages
addsitedir(sitedir, known_paths)
File "/usr/lib64/python2.6/site.py", line 185, in addsitedir
addpackage(sitedir, name, known_paths)
File "/usr/lib64/python2.6/site.py", line 159, in addpackage
if not dircase in known_paths and os.path.exists(dir):
File "/usr/lib64/python2.6/genericpath.py", line 18, in exists
st = os.stat(path)
TypeError: stat() argument 1 must be encoded string without NULL bytes,
not str
I'm puzzled and I'd appreciate any hints to the reason for this failure.

Many thanks,
Helmut.
 
S

Stefan Sonnenberg-Carstens

Am 12.11.2010 19:32, schrieb Helmut Jarausch:
Hi,

as often before, I've cloned a working system (GenToo) onto another
machine. There, from a livecd and chroot to the cloned root partition

python -v
import site

fails with the following error
Python 2.6.6 (r266:84292, Oct 13 2010, 09:06:24)
[GCC 4.4.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
dlopen("/usr/lib64/python2.6/lib-dynload/readline.so", 2);
import readline # dynamically loaded from /usr/lib64/python2.6/lib-
dynload/readline.so# /usr/lib64/python2.6/site.pyc matches /usr/lib64/python2.6/site.py
import site # precompiled from /usr/lib64/python2.6/site.pyc
Traceback (most recent call last):
File "<stdin>", line 1, in<module>
File "/usr/lib64/python2.6/site.py", line 526, in<module>
main()
File "/usr/lib64/python2.6/site.py", line 509, in main
known_paths = addsitepackages(known_paths)
File "/usr/lib64/python2.6/site.py", line 289, in addsitepackages
addsitedir(sitedir, known_paths)
File "/usr/lib64/python2.6/site.py", line 185, in addsitedir
addpackage(sitedir, name, known_paths)
File "/usr/lib64/python2.6/site.py", line 159, in addpackage
if not dircase in known_paths and os.path.exists(dir):
File "/usr/lib64/python2.6/genericpath.py", line 18, in exists
st = os.stat(path)
TypeError: stat() argument 1 must be encoded string without NULL bytes,
not strI'm puzzled and I'd appreciate any hints to the reason for this failure.

Many thanks,
Helmut.
You gave the answer yourself.
Chrooting does not automatically mean your SO cache is where it should
be for the target system.
Perhaps your livecd is newer/older than the target system or simply the
python in live environment
is not (most likely) compiled as the one in the target system.

That is _one_ reason I stoped using gentoo and switched to debian/ubuntu.
 
H

Helmut Jarausch

Am 12.11.2010 19:32, schrieb Helmut Jarausch:
Hi,

as often before, I've cloned a working system (GenToo) onto another
machine. There, from a livecd and chroot to the cloned root partition

python -v
import site

fails with the following error
Python 2.6.6 (r266:84292, Oct 13 2010, 09:06:24) [GCC 4.4.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
dlopen("/usr/lib64/python2.6/lib-dynload/readline.so", 2); import
readline # dynamically loaded from /usr/lib64/python2.6/lib-
dynload/readline.so
import site
# /usr/lib64/python2.6/site.pyc matches /usr/lib64/python2.6/site.py
import site # precompiled from /usr/lib64/python2.6/site.pyc Traceback
(most recent call last):
File "<stdin>", line 1, in<module>
File "/usr/lib64/python2.6/site.py", line 526, in<module>
main()
File "/usr/lib64/python2.6/site.py", line 509, in main
known_paths = addsitepackages(known_paths)
File "/usr/lib64/python2.6/site.py", line 289, in addsitepackages
addsitedir(sitedir, known_paths)
File "/usr/lib64/python2.6/site.py", line 185, in addsitedir
addpackage(sitedir, name, known_paths)
File "/usr/lib64/python2.6/site.py", line 159, in addpackage
if not dircase in known_paths and os.path.exists(dir):
File "/usr/lib64/python2.6/genericpath.py", line 18, in exists
st = os.stat(path)
TypeError: stat() argument 1 must be encoded string without NULL bytes,
not str
I'm puzzled and I'd appreciate any hints to the reason for this
failure.

Many thanks,
Helmut.
You gave the answer yourself.
Chrooting does not automatically mean your SO cache is where it should
be for the target system.
Perhaps your livecd is newer/older than the target system or simply the
python in live environment
is not (most likely) compiled as the one in the target system.

It has been working dozens of time!
Are you saying, an ldconfig would rectify the situation?

Unfortunately, I can only test it on monday.

Thanks,
Helmut.
 
S

Stefan Sonnenberg-Carstens

Am 12.11.2010 20:24, schrieb Helmut Jarausch:
Am 12.11.2010 19:32, schrieb Helmut Jarausch:
Hi,

as often before, I've cloned a working system (GenToo) onto another
machine. There, from a livecd and chroot to the cloned root partition

python -v
import site

fails with the following error
Python 2.6.6 (r266:84292, Oct 13 2010, 09:06:24) [GCC 4.4.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
dlopen("/usr/lib64/python2.6/lib-dynload/readline.so", 2); import
readline # dynamically loaded from /usr/lib64/python2.6/lib-
dynload/readline.so
import site
# /usr/lib64/python2.6/site.pyc matches /usr/lib64/python2.6/site.py
import site # precompiled from /usr/lib64/python2.6/site.pyc Traceback
(most recent call last):
File "<stdin>", line 1, in<module>
File "/usr/lib64/python2.6/site.py", line 526, in<module>
main()
File "/usr/lib64/python2.6/site.py", line 509, in main
known_paths = addsitepackages(known_paths)
File "/usr/lib64/python2.6/site.py", line 289, in addsitepackages
addsitedir(sitedir, known_paths)
File "/usr/lib64/python2.6/site.py", line 185, in addsitedir
addpackage(sitedir, name, known_paths)
File "/usr/lib64/python2.6/site.py", line 159, in addpackage
if not dircase in known_paths and os.path.exists(dir):
File "/usr/lib64/python2.6/genericpath.py", line 18, in exists
st = os.stat(path)
TypeError: stat() argument 1 must be encoded string without NULL bytes,
not str
​
I'm puzzled and I'd appreciate any hints to the reason for this
failure.

Many thanks,
Helmut.
You gave the answer yourself.
Chrooting does not automatically mean your SO cache is where it should
be for the target system.
Perhaps your livecd is newer/older than the target system or simply the
python in live environment
is not (most likely) compiled as the one in the target system.
It has been working dozens of time!
Are you saying, an ldconfig would rectify the situation?

Unfortunately, I can only test it on monday.

Thanks,
Helmut.
It works as long as the so files are close enough in the way they were
built,
the symbols they expose and the versions they have.
calling ldconfig _can_ help, but this is not for sure.
You can of course try to call

ldd /usr/bin/python (or where it lives)
and
ldd /usr/lib64/python2.6/lib-dynload/readline.so

to see if there is something abviously wrong.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,955
Messages
2,570,117
Members
46,705
Latest member
v_darius

Latest Threads

Top