Python中的“SyntaxError:无效语法”

时间:2015-04-03 01:47:18

标签: python-2.7 odoo

我在我的服务器上安装了odoo,它有Python 2.7.9。当我尝试启动守护程序时,我收到此错误:

root@des [/opt/odoo/openerp]# /etc/init.d/odoo start
Starting Odoo Server Daemon (odoo-server):                 [  OK  ]
root@des [/opt/odoo/openerp]# 'import site' failed; use -v for traceback
Traceback (most recent call last):
  File "/opt/odoo/openerp-server", line 2, in ?
    import openerp
  File "/opt/odoo/openerp/__init__.py", line 90
    from . import models
         ^
SyntaxError: invalid syntax

这是Python信息:

root@des [/opt/odoo/openerp]# python
Python 2.7.9 (default, Apr  2 2015, 20:06:47)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-55)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

这是我的环境:

root@des [/opt/odoo/openerp]# uname -a
Linux des.desytec.com 2.6.32-042stab104.1 #1 SMP Thu Jan 29 12:58:41 MSK 2015 x86_64 x86_64 x86_64 GNU/Linux

编辑:

感谢Tevfik的回答,我已经解决了错误,但是,现在Python库中出现了语法错误。这怎么可能,我可以解决它?

root@des [/usr/local/lib/python2.7]# /etc/init.d/odoo start
Starting Odoo Server Daemon (odoo-server):                 [  OK  ]
root@des [/usr/local/lib/python2.7]# 'import site' failed; use -v for traceback
Traceback (most recent call last):
  File "/opt/odoo/openerp-server", line 2, in ?
    import openerp
  File "/opt/odoo/openerp/__init__.py", line 47, in ?
    import os
  File "/usr/local/lib/python2.7/os.py", line 49, in ?
    import posixpath as path
  File "/usr/local/lib/python2.7/posixpath.py", line 339
    slash, dot = (u'/', u'.') if isinstance(path, _unicode) else ('/', '.')
                               ^
SyntaxError: invalid syntax

root@des [/usr/local/lib/python2.7]#

任何帮助将不胜感激 感谢

的Jaime

1 个答案:

答案 0 :(得分:0)

尝试这种语法

from «app_name».models import *