You are not logged in.

#1 2010-10-27 09:27:32

qiuwei
Member
Registered: 2009-12-18
Posts: 245

[solved]Something wrong with python

After A full system upgrade,
I can run python in my home directory and / normally.(EDIT: here "run python" means typing "python" in the terminal but not running any python script.)
But if  I change directory to /usr/lib and run python I will get a segmentation fault.
if I change directory to /usr/lib/python2.5, the error seems more weired:

Fatal Python error: Py_Initialize: can't initialize sys standard streams
Traceback (most recent call last):
  File "encodings/utf_8.py", line 9, in <module>
  File "codecs.py", line 16
    except ImportError, why:
                      ^
SyntaxError: invalid syntax
Aborted

Is this a bug?

btw: I cannot run knoda now:

knoda: error while loading shared libraries: libpython2.6.so.1.0: cannot open shared object file: No such file or directory

I also can't recompile the package:

/usr/bin/ld: cannot find -lpython2.6
collect2: ld returned 1 exit status

How can I fix this? downgrade to python2.6?
thx!
==========update=============
It was caused by google-appengine toolkit. It set PYTHONPATH to "/opt/google-appengine". Unset it and everything goes well.

Last edited by qiuwei (2010-10-29 08:23:35)

Offline

#2 2010-10-27 10:07:25

linux-ka
Member
From: ADL
Registered: 2010-05-07
Posts: 232

Re: [solved]Something wrong with python

Do you have this libpython2.6.so.1.0 in your system?

Further, after a full system upgrade you should have installed python2.7. So what kind of mirror did you use? have a look for /etc/pacman.d/mirrorlist.pacnew and move it to /etc/pacman.d/mirrorlist.
Next, install python and python2.

Offline

#3 2010-10-27 10:16:42

qiuwei
Member
Registered: 2009-12-18
Posts: 245

Re: [solved]Something wrong with python

linux-ka wrote:

Do you have this libpython2.6.so.1.0 in your system?

Further, after a full system upgrade you should have installed python2.7. So what kind of mirror did you use? have a look for /etc/pacman.d/mirrorlist.pacnew and move it to /etc/pacman.d/mirrorlist.
Next, install python and python2.

Maybe I don't describe the problem clearly. I've installed python and python2 but there is no libpython2.6.so.10 but libpython2.7.so.10 and libpython2.5.so.10. exists.
What about the first problem? In some directories if i run python in terminal I will get a segmentation fault.
Thanks for your reply!

Offline

#4 2010-10-27 10:34:55

linux-ka
Member
From: ADL
Registered: 2010-05-07
Posts: 232

Re: [solved]Something wrong with python

1) make a link from libpython2.7.so.10  to libpython2.6.so.10...that's not fine, but might help.

I guess it looks like your python cannot deal with some latters which have to be described via utf-8 char set,...you obtain the same error when starting python and python2?

EDIT:

write this into your /usr/lib/python2.7/site.py:

sys.setdefaultencoding('utf8')

It helped in many cases where I got trouble with encodings

Last edited by linux-ka (2010-10-27 10:41:20)

Offline

#5 2010-10-27 10:46:28

qiuwei
Member
Registered: 2009-12-18
Posts: 245

Re: [solved]Something wrong with python

linux-ka wrote:

1) make a link from libpython2.7.so.10  to libpython2.6.so.10...that's not fine, but might help.

I guess it looks like your python cannot deal with some latters which have to be described via utf-8 char set,...you have the same error when starting python and python2?

I've tried to link libpython2.7.so.10 to libpython2.6.so.10, knoda crashes sometimes.
Python2 works well no matter in which directory but python sometimes goes wrong.

Offline

#6 2010-10-27 10:54:31

linux-ka
Member
From: ADL
Registered: 2010-05-07
Posts: 232

Re: [solved]Something wrong with python

well, ...maybe you should use python2 instead of python (3)...have you tried the encoding setup in the site.py? you might also try it in python3.1/site.py...
Further, go to the knoda at `which knoda`, and change the shebang to python2 or python2.7. This might force kanoda to be run by python2.7.

EDIT:

Furthermore, install knoda again by editing the PKGBUILD. Change the used python to python2.7.

Last edited by linux-ka (2010-10-27 10:55:51)

Offline

#7 2010-10-27 12:07:15

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,097

Re: [solved]Something wrong with python

linux-ka wrote:

1) make a link from libpython2.7.so.10  to libpython2.6.so.10...that's not fine, but might help.

Do not symlink, it will not work, and it will only cause more problems.

There is only one real solution. Rebuild/reinstall the application.

http://allanmcrae.com/2010/10/big-pytho … rch-linux/
http://www.archlinux.org/news/python-is-now-python-3/

You have to reinstall all packages that owns files in /usr/lib/python2.{5|6}/

Last edited by Mr.Elendig (2010-10-27 12:12:56)


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#8 2010-10-27 14:21:45

kachelaqa
Member
Registered: 2010-09-26
Posts: 216

Re: [solved]Something wrong with python

qiuwei wrote:

After A full system upgrade,
I can run python in my home directory and / normally.
But if  I change directory to /usr/lib and run python I will get a segmentation fault.
if I change directory to /usr/lib/python2.5, the error seems more weired:

Fatal Python error: Py_Initialize: can't initialize sys standard streams
Traceback (most recent call last):
  File "encodings/utf_8.py", line 9, in <module>
  File "codecs.py", line 16
    except ImportError, why:
                      ^
SyntaxError: invalid syntax
Aborted

Is this a bug?

no. it is caused by you trying to run python2 code which is incompatible with python3.

btw: I cannot run knoda now:

knoda: error while loading shared libraries: libpython2.6.so.1.0: cannot open shared object file: No such file or directory

I also can't recompile the package:

/usr/bin/ld: cannot find -lpython2.6
collect2: ld returned 1 exit status

it appears that knoda depends on python2.6, which no longer exists on your system.

How can I fix this? downgrade to python2.6?
thx!

knoda appears to be a really old db front-end for kde3.

you'd be better off looking for a more modern replacement, like kexi: http://www.kexi-project.org/

Offline

#9 2010-10-27 16:06:59

eldragon
Member
From: Buenos Aires
Registered: 2008-11-18
Posts: 1,029

Re: [solved]Something wrong with python

as it was stated before. symlinking shared objects is bound to bring system breakage too difficult to debug in the future.
if there is a soname bump, and some apps depend on it, they need to be rebuilt against the new so's and if they fail to do so. report upstream (prior search on their mailing lists concerning the issue).

and if you are lazy...downgrade the libraries and wait. (or simply wait).

Last edited by eldragon (2010-10-27 16:08:15)

Offline

#10 2010-10-27 21:32:35

murr
Member
From: UK
Registered: 2008-04-01
Posts: 11

Re: [solved]Something wrong with python

As far as knoda is concerned, it is not knoda itself that needs rebuilding for python 2.7, but hk_classes, the library on which knoda depends.  It is possible to do so by amending the PKGBUILD and patching the makefile.  If you want to continue to use knoda then I can make the amended PKGBUILD and the patch for hk_classes available in a pastebin.  However, as already mentioned, there has been no development for nearly 4 years, so you might be better off looking for a replacement.

Offline

#11 2010-10-28 01:41:50

qiuwei
Member
Registered: 2009-12-18
Posts: 245

Re: [solved]Something wrong with python

kachelaqa wrote:
qiuwei wrote:

After A full system upgrade,
I can run python in my home directory and / normally.
But if  I change directory to /usr/lib and run python I will get a segmentation fault.
if I change directory to /usr/lib/python2.5, the error seems more weired:

Fatal Python error: Py_Initialize: can't initialize sys standard streams
Traceback (most recent call last):
  File "encodings/utf_8.py", line 9, in <module>
  File "codecs.py", line 16
    except ImportError, why:
                      ^
SyntaxError: invalid syntax
Aborted

Is this a bug?

no. it is caused by you trying to run python2 code which is incompatible with python3.

btw: I cannot run knoda now:

knoda: error while loading shared libraries: libpython2.6.so.1.0: cannot open shared object file: No such file or directory

I also can't recompile the package:

/usr/bin/ld: cannot find -lpython2.6
collect2: ld returned 1 exit status

it appears that knoda depends on python2.6, which no longer exists on your system.

How can I fix this? downgrade to python2.6?
thx!

knoda appears to be a really old db front-end for kde3.

you'd be better off looking for a more modern replacement, like kexi: http://www.kexi-project.org/

Maybe I don't explain it well. I'm not running any script but just type "python" in the terminal within different directories and get those errors.

Offline

#12 2010-10-28 01:42:52

qiuwei
Member
Registered: 2009-12-18
Posts: 245

Re: [solved]Something wrong with python

murr wrote:

As far as knoda is concerned, it is not knoda itself that needs rebuilding for python 2.7, but hk_classes, the library on which knoda depends.  It is possible to do so by amending the PKGBUILD and patching the makefile.  If you want to continue to use knoda then I can make the amended PKGBUILD and the patch for hk_classes available in a pastebin.  However, as already mentioned, there has been no development for nearly 4 years, so you might be better off looking for a replacement.

Thank you for your advice. I will try it.

Offline

#13 2010-10-28 12:45:20

kachelaqa
Member
Registered: 2010-09-26
Posts: 216

Re: [solved]Something wrong with python

qiuwei wrote:

Maybe I don't explain it well. I'm not running any script but just type "python" in the terminal within different directories and get those errors.

the traceback you posted is caused by trying to use python2 syntax in python3. let me demonstrate:

$python2
Python 2.7 (r27:82500, Oct  6 2010, 12:18:19) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> try: import foo
... except ImportError, why: pass
... 
>>>
$ python3
Python 3.1.2 (r312:79147, Oct  4 2010, 12:35:40) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> try: import foo
... except ImportError, why: pass
  File "<stdin>", line 2
    except ImportError, why: pass
                      ^
SyntaxError: invalid syntax
>>>

do you have a python startup file? the commands in that file are executed every time an interactive session is started. check $PYTHONSTARTUP to find its location (usually ~/.pythonrc.py).

Offline

#14 2010-10-28 12:56:02

qiuwei
Member
Registered: 2009-12-18
Posts: 245

Re: [solved]Something wrong with python

kachelaqa wrote:
qiuwei wrote:

Maybe I don't explain it well. I'm not running any script but just type "python" in the terminal within different directories and get those errors.

the traceback you posted is caused by trying to use python2 syntax in python3. let me demonstrate:

$python2
Python 2.7 (r27:82500, Oct  6 2010, 12:18:19) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> try: import foo
... except ImportError, why: pass
... 
>>>
$ python3
Python 3.1.2 (r312:79147, Oct  4 2010, 12:35:40) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> try: import foo
... except ImportError, why: pass
  File "<stdin>", line 2
    except ImportError, why: pass
                      ^
SyntaxError: invalid syntax
>>>

do you have a python startup file? the commands in that file are executed every time an interactive session is started. check $PYTHONSTARTUP to find its location (usually ~/.pythonrc.py).

Sorry for my poor English, I think you didn't catch me well.

[jiuren@Jiuren-host lib]$ pwd
/usr/lib
[jiuren@Jiuren-host lib]$ python
Segmentation fault
[jiuren@Jiuren-host lib]$ python2
Python 2.7 (r27:82500, Oct  6 2010, 12:18:19) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
[jiuren@Jiuren-host python2.5]$ pwd
/usr/lib/python2.5
[jiuren@Jiuren-host python2.5]$ python
Fatal Python error: Py_Initialize: can't initialize sys standard streams
Traceback (most recent call last):
  File "encodings/utf_8.py", line 9, in <module>
  File "codecs.py", line 16
    except ImportError, why:
                      ^
SyntaxError: invalid syntax
Aborted

However,

[jiuren@Jiuren-host /]$ pwd
/
[jiuren@Jiuren-host /]$ python
Python 3.1.2 (r312:79147, Oct  4 2010, 12:35:40) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
[jiuren@Jiuren-host ~]$ pwd
/home/jiuren
[jiuren@Jiuren-host ~]$ python
Python 3.1.2 (r312:79147, Oct  4 2010, 12:35:40) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

and python2 can run with no problem in any directory. I'm not running any scripts or import any modules. I don't find .pythonrc.py in my home directory and $PYTHONSTARTUP is empty.

Offline

#15 2010-10-28 13:07:01

kachelaqa
Member
Registered: 2010-09-26
Posts: 216

Re: [solved]Something wrong with python

qiuwei wrote:

Sorry for my poor English, I think you didn't catch me well.

your english is good. i understand you fine smile

[jiuren@Jiuren-host lib]$ pwd
/usr/lib
[jiuren@Jiuren-host lib]$ python
Segmentation fault
[jiuren@Jiuren-host lib]$ python2
Python 2.7 (r27:82500, Oct  6 2010, 12:18:19) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
[jiuren@Jiuren-host python2.5]$ pwd
/usr/lib/python2.5
[jiuren@Jiuren-host python2.5]$ python
Fatal Python error: Py_Initialize: can't initialize sys standard streams
Traceback (most recent call last):
  File "encodings/utf_8.py", line 9, in <module>
  File "codecs.py", line 16
    except ImportError, why:
                      ^
SyntaxError: invalid syntax
Aborted

the current directory is always the first item in sys.path, so python will try to import modules from there first. obviously, it is trying to import the codecs module from "/usr/lib/python2.5" and it fails, because the code in that module is incompatible with python3.

so the solution to this problem is: don't do that.

However,

[jiuren@Jiuren-host /]$ pwd
/
[jiuren@Jiuren-host /]$ python
Python 3.1.2 (r312:79147, Oct  4 2010, 12:35:40) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
[jiuren@Jiuren-host ~]$ pwd
/home/jiuren
[jiuren@Jiuren-host ~]$ python
Python 3.1.2 (r312:79147, Oct  4 2010, 12:35:40) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

and python2 can run with no problem in any directory. I'm not running any scripts or import any modules. I don't find .pythonrc.py in my home directory and $PYTHONSTARTUP is empty.

try running "python -S" in the directories that cause the segmentation fault. do you still get the errors?

Last edited by kachelaqa (2010-10-28 13:26:25)

Offline

#16 2010-10-28 14:04:53

qiuwei
Member
Registered: 2009-12-18
Posts: 245

Re: [solved]Something wrong with python

kachelaqa wrote:
qiuwei wrote:

Sorry for my poor English, I think you didn't catch me well.

your english is good. i understand you fine smile

[jiuren@Jiuren-host lib]$ pwd
/usr/lib
[jiuren@Jiuren-host lib]$ python
Segmentation fault
[jiuren@Jiuren-host lib]$ python2
Python 2.7 (r27:82500, Oct  6 2010, 12:18:19) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
[jiuren@Jiuren-host python2.5]$ pwd
/usr/lib/python2.5
[jiuren@Jiuren-host python2.5]$ python
Fatal Python error: Py_Initialize: can't initialize sys standard streams
Traceback (most recent call last):
  File "encodings/utf_8.py", line 9, in <module>
  File "codecs.py", line 16
    except ImportError, why:
                      ^
SyntaxError: invalid syntax
Aborted

However,

[jiuren@Jiuren-host /]$ pwd
/
[jiuren@Jiuren-host /]$ python
Python 3.1.2 (r312:79147, Oct  4 2010, 12:35:40) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
[jiuren@Jiuren-host ~]$ pwd
/home/jiuren
[jiuren@Jiuren-host ~]$ python
Python 3.1.2 (r312:79147, Oct  4 2010, 12:35:40) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

so you have confirmed what i demonstrated. python2 works, but python3 doesn't, because it is somehow running some python2 code.

and python2 can run with no problem in any directory. I'm not running any scripts or import any modules. I don't find .pythonrc.py in my home directory and $PYTHONSTARTUP is empty.

try running "python -S" in the directories that cause the problem. do you still get the errors?

It doesn't help. It seems a problem with my system. I tried on another arch system and python works fine.

Last edited by qiuwei (2010-10-28 14:09:27)

Offline

#17 2010-10-28 14:18:05

linux-ka
Member
From: ADL
Registered: 2010-05-07
Posts: 232

Re: [solved]Something wrong with python

Why don't you set the $PYTHONSTARTUP to /home/<user>/.pythonrc.py?

In my opinion sth went terribly wrong within your last upgrades. Maybe sth was installed via python3 instead of python2, which was recommended...or the other way around.
Purge everything related to python and reinstall these parts. ...But this sounds more or less like a M$ solution....sry.

EDIT:

.pythonrc.py just looks like this (which is one of my currently used).

import glob
import numpy
import Gnuplot
import scipy
import sys

gl=glob.glob
np=numpy
gp=Gnuplot.Gnuplot()

sys.path.append("/home/<user>/scripts/Python")
taxes=lambda x: x*0.19 + x
del sys
from myfunc import *

Last edited by linux-ka (2010-10-28 14:19:21)

Offline

#18 2010-10-28 15:34:29

qiuwei
Member
Registered: 2009-12-18
Posts: 245

Re: [solved]Something wrong with python

linux-ka wrote:

Why don't you set the $PYTHONSTARTUP to /home/<user>/.pythonrc.py?

In my opinion sth went terribly wrong within your last upgrades. Maybe sth was installed via python3 instead of python2, which was recommended...or the other way around.
Purge everything related to python and reinstall these parts. ...But this sounds more or less like a M$ solution....sry.

EDIT:

.pythonrc.py just looks like this (which is one of my currently used).

import glob
import numpy
import Gnuplot
import scipy
import sys

gl=glob.glob
np=numpy
gp=Gnuplot.Gnuplot()

sys.path.append("/home/<user>/scripts/Python")
taxes=lambda x: x*0.19 + x
del sys
from myfunc import *

Actually I think some terrible things happened to my system.
when I'm in /usr/lib/python 3.1, if I type "cd p" then type tab to auto complete, I get errors as below:

[jiuren@Jiuren-host python3.1]$ cd pTraceback (most recent call last):
  File "site.py", line 56, in <module>
    import os
  File "os.py", line 380, in <module>
    from _abcoll import MutableMapping  # Can't use collections (bootstrap)
  File "_abcoll.py", line 54
    class Hashable(metaclass=ABCMeta):
                            ^
SyntaxError: invalid syntax

Offline

#19 2010-10-28 15:47:59

linux-ka
Member
From: ADL
Registered: 2010-05-07
Posts: 232

Re: [solved]Something wrong with python

hmm seems so.

Mysterious...why is cd and path completion related to python modules? Are you still able to upgrade your system? It can't get worse sad

Offline

#20 2010-10-28 17:41:36

kachelaqa
Member
Registered: 2010-09-26
Posts: 216

Re: [solved]Something wrong with python

qiuwei wrote:

Actually I think some terrible things happened to my system.
when I'm in /usr/lib/python 3.1, if I type "cd p" then type tab to auto complete, I get errors as below:

[jiuren@Jiuren-host python3.1]$ cd pTraceback (most recent call last):
  File "site.py", line 56, in <module>
    import os
  File "os.py", line 380, in <module>
    from _abcoll import MutableMapping  # Can't use collections (bootstrap)
  File "_abcoll.py", line 54
    class Hashable(metaclass=ABCMeta):
                            ^
SyntaxError: invalid syntax

is there some specific reason why you are continually working within the python lib dirs?

i explained in my previous post why that can sometimes cause problems (it screws around with python imports).

Offline

#21 2010-10-29 08:21:19

qiuwei
Member
Registered: 2009-12-18
Posts: 245

Re: [solved]Something wrong with python

Now this problem has been solved. There is a environment variable PYTHONPATH="/opt/google-appengine" in my system.
Just unset it and everything goes well. Seems a bug of google-appenginie in the aur?

Offline

Board footer

Powered by FluxBB