2015-04-03 102 views
1

我在裝有Python 2.7.9的服務器中安裝了odoo。當我嘗試啓動守護進程,我得到這個錯誤:Python中的「SyntaxError:invalid syntax」

[email protected] [/opt/odoo/openerp]# /etc/init.d/odoo start 
Starting Odoo Server Daemon (odoo-server):     [ OK ] 
[email protected] [/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的信息:

[email protected] [/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. 
>>> 

這是我的環境:

[email protected] [/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庫中產生了一個語法錯誤。我可以如何解決這個問題?

[email protected] [/usr/local/lib/python2.7]# /etc/init.d/odoo start 
Starting Odoo Server Daemon (odoo-server):     [ OK ] 
[email protected] [/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 

[email protected] [/usr/local/lib/python2.7]# 

任何幫助將不勝感激 感謝

海梅

+0

什麼是'.'?這是一條路嗎? – 2015-04-03 01:51:34

+0

@James_Parsons:它是[相對導入語法](https://www.python.org/dev/peps/pep-0328/)。 – user2357112 2015-04-03 01:55:24

+0

@jstuardo:你用任何方式搞定了你的odoo安裝嗎?對其文件執行編輯或更改配置? – user2357112 2015-04-03 01:58:38

回答

0

試試這個語法

from «app_name».models import * 
+0

下載的軟件包的'setup.py'中'setup'函數調用的關鍵字參數謝謝...我已經用您的解決方案更新了問題。現在,Python庫中存在語法錯誤。我不知道這怎麼可能,我對Python一無所知,但我需要安裝用這種語言開發的Odoo。 – jstuardo 2015-04-03 02:13:32