2013-03-06 42 views
0

我的appengine應用程序中有一個挑戰導入ast(抽象語法樹)模塊的挑戰。在我的本地開發機器上,一切工作正常,但在將應用程序部署到生產appengine後,出現以下錯誤;我如何在google appengine中導入ast模塊

<type 'exceptions.ImportError'>: No module named ast 
Traceback (most recent call last): 
    File "/base/data/home/apps/s~appname/1.365758902437943607/main.py", line 3, in <module> 
    import ast 

谷歌appengine是否支持ast模塊?

迦特

+0

'ast'是在Python 2.6中引入的(在Python 2.5中爲'_ast')。檢查你的Python版本,看看它是否至少有2.6 – dmg 2013-03-06 08:38:52

+0

在我的開發機器上使用2.6和2.7 – gath 2013-03-06 09:00:17

+1

你的本地機器在這種情況下並不重要。你必須檢查你的GAE Python版本。由於我幾乎可以肯定它將是2.5,所以你可以看看[這個遷移指南](https://developers.google.com/appengine/docs/python/python25/migrate27) – dmg 2013-03-06 09:03:25

回答

3

ast模塊是在Python 2.6引入了(它是下級對口_ast在Python 2.5中,儘管你的開發機器上安裝了Python 2.6+,但對於GAE生產環境無關緊要。請看this migration guide以便從Python 2.5遷移GAE環境到Python 2.7。

0

檢查部署主機上的版本的Python

python -V 

ISTR AST不是在Python 2.5

+0

正在使用2.6&2.7 – gath 2013-03-06 08:59:48

+1

這與您在本地開發服務器上使用的無關。 – 2013-03-06 09:11:05

+0

@Paul C - 你說得對,當時正在運行2.5,將生產遷移到2.7,謝謝。 – gath 2013-03-06 09:47:40