Discussion:
lyxpak not working
stefano franchi
2014-06-01 18:24:40 UTC
Permalink
Dear All:

I am trying to use lyxpak and it fails due to python-related issues. This
happens both in lyx2.1 and 2.0. I think it maybe a platform-specific issue
(Arch) due to some environmental variables not set by default, or to some
python2/python3 conflict. At any rate, I can't figure out how to fix it.
Here is the error message:

12:56:57.302: Fatal Python error: Py_Initialize: Unable to get the locale
encoding

12:56:57.303: File "/usr/lib/python2.7/encodings/__init__.py", line 123

12:56:57.304: raise CodecRegistryError,\

12:56:57.305: ^

12:56:57.306: SyntaxError: invalid syntax



which is puzzling, since it seems to say that there is a problem with the
syntax of the raise statement. Source code of the encodings file:


if not isinstance(entry, codecs.CodecInfo):
if not 4 <= len(entry) <= 7:
raise CodecRegistryError,\
'module "%s" (%s) failed to register' % \
(mod.__name__, mod.__file__)


As far as I can tell, the syntax of raise used here is indeed wrong if used
in python 3 (where raise Exception("excp") should be used). But why is
python 3 called at all, when lyxpak is correctly called as

/usr/bin/python2 -tt "/usr/local/share/lyx-2.1/scripts/lyxpak.py" ?


Secondly, the fact that the encodings module tries to raise an exception
means it has failed to find the correct module, I think.


So the two problems are most likely just one problem, due to some
interaction between python2 and python 3 on my system.


Any suggestion?



Cheers,


Stefano
--
__________________________________________________
Stefano Franchi
Associate Research Professor
Department of Hispanic Studies Ph: +1 (979) 845-2125
Texas A&M University Fax: +1 (979) 845-6421
College Station, Texas, USA

***@tamu.edu
http://stefano.cleinias.org
stefano franchi
2014-06-01 18:37:37 UTC
Permalink
Post by stefano franchi
I am trying to use lyxpak and it fails due to python-related issues. This
happens both in lyx2.1 and 2.0. I think it maybe a platform-specific issue
(Arch) due to some environmental variables not set by default, or to some
python2/python3 conflict. At any rate, I can't figure out how to fix it.
12:56:57.302: Fatal Python error: Py_Initialize: Unable to get the locale
encoding
12:56:57.303: File "/usr/lib/python2.7/encodings/__init__.py", line 123
12:56:57.304: raise CodecRegistryError,\
12:56:57.305: ^
12:56:57.306: SyntaxError: invalid syntax
which is puzzling, since it seems to say that there is a problem with the
raise CodecRegistryError,\
'module "%s" (%s) failed to register' % \
(mod.__name__, mod.__file__)
As far as I can tell, the syntax of raise used here is indeed wrong if
used in python 3 (where raise Exception("excp") should be used). But why is
python 3 called at all, when lyxpak is correctly called as
/usr/bin/python2 -tt "/usr/local/share/lyx-2.1/scripts/lyxpak.py" ?
Secondly, the fact that the encodings module tries to raise an exception
means it has failed to find the correct module, I think.
So the two problems are most likely just one problem, due to some
interaction between python2 and python 3 on my system.
Any suggestion?
Further info:

- "python" defaults to python3 on my system

- my python3 installation is broken, and indeed launching "python" from
the command line gives me exactly the same error as lyxpak.py


So the issue seems to be that lyxpak indirectly calls "python" at some
points, this calls ends up calling python3, which fails.

I still do not understand where this misguided call to python3 comes into
the picture, though.


S.
--
__________________________________________________
Stefano Franchi
Associate Research Professor
Department of Hispanic Studies Ph: +1 (979) 845-2125
Texas A&M University Fax: +1 (979) 845-6421
College Station, Texas, USA

***@tamu.edu
http://stefano.cleinias.org
Kornel Benko
2014-06-01 18:48:03 UTC
Permalink
Post by stefano franchi
Post by stefano franchi
I am trying to use lyxpak and it fails due to python-related issues. This
happens both in lyx2.1 and 2.0. I think it maybe a platform-specific issue
(Arch) due to some environmental variables not set by default, or to some
python2/python3 conflict. At any rate, I can't figure out how to fix it.
12:56:57.302: Fatal Python error: Py_Initialize: Unable to get the locale
encoding
12:56:57.303: File "/usr/lib/python2.7/encodings/__init__.py", line 123
12:56:57.304: raise CodecRegistryError,\
12:56:57.305: ^
12:56:57.306: SyntaxError: invalid syntax
which is puzzling, since it seems to say that there is a problem with the
raise CodecRegistryError,\
'module "%s" (%s) failed to register' % \
(mod.__name__, mod.__file__)
As far as I can tell, the syntax of raise used here is indeed wrong if
used in python 3 (where raise Exception("excp") should be used). But why is
python 3 called at all, when lyxpak is correctly called as
/usr/bin/python2 -tt "/usr/local/share/lyx-2.1/scripts/lyxpak.py" ?
Secondly, the fact that the encodings module tries to raise an exception
means it has failed to find the correct module, I think.
So the two problems are most likely just one problem, due to some
interaction between python2 and python 3 on my system.
Any suggestion?
- "python" defaults to python3 on my system
- my python3 installation is broken, and indeed launching "python" from
the command line gives me exactly the same error as lyxpak.py
So the issue seems to be that lyxpak indirectly calls "python" at some
points, this calls ends up calling python3, which fails.
I still do not understand where this misguided call to python3 comes into
the picture, though.
You could try to trace it, like this on linux:

# strace -f -o xx /usr/bin/python2 -tt "/usr/local/share/lyx-2.1/scripts/lyxpak.py"
Post by stefano franchi
S.
Kornel
Kornel Benko
2014-06-01 18:51:19 UTC
Permalink
Post by Kornel Benko
# strace -f -o xx /usr/bin/python2 -tt "/usr/local/share/lyx-2.1/scripts/lyxpak.py"
S.
The equivalent for strace on mac may be ktrace.

Kornel
stefano franchi
2014-06-01 22:31:21 UTC
Permalink
Post by stefano franchi
Post by Kornel Benko
# strace -f -o xx /usr/bin/python2 -tt
"/usr/local/share/lyx-2.1/scripts/lyxpak.py"
Post by Kornel Benko
S.
Thanks Kornel. strace worked and found the root of the problem

It is definitely an installation problem: the python module collections.py
try to load an internal C module called _collections and fails to find it.
The module is actually present on my system at

/usr/lib/python2.7/lib-dynload/_collections.so

but somehow python2 cannot find it. Still trying to find a solution.

Cheers,


S.
--
__________________________________________________
Stefano Franchi
Associate Research Professor
Department of Hispanic Studies Ph: +1 (979) 845-2125
Texas A&M University Fax: +1 (979) 845-6421
College Station, Texas, USA

***@tamu.edu
http://stefano.cleinias.org
Loading...