簡體   English   中英

zc.buildout使用錯誤的python

[英]zc.buildout is using the wrong python

我正在使用zc.buildout生成一個名為“ test”的腳本。 我正在使用該腳本來調用我自己的測試運行程序。 (用於擴展的可用測試運行程序尚未使用Python 2.7中的新“發現”功能。)

無論如何,這是我的.cfg文件中的相關部分:

[test]
recipe = buildout_script
template = runtests.sh.in
target = test

這是我的runtests.sh.in模板的樣子

#!/bin/bash

python %(directory)s/src/runtests.py

這是結果輸出,作為bin/test放在我的bin文件夾中。

!/bin/bash

python /Users/myname/projects/myproject/trunk/www/src/desktop/src/runtests.py

執行此腳本時,它使用的是系統Python,而不是bin文件夾中的Python。

我的.cfg文件中與此相關的部分是:

[python]
recipe = zc.recipe.egg
interpreter = python
eggs = ${buildout:eggs}

如何獲取腳本以使用bin / python而不是系統python?

在您的bash腳本中,您依靠$PATH確定要使用哪個python。 要更改調用哪個python,您有幾種選擇:

  1. 修改您的環境以使用其他版本,例如,在〜/ .bashrc中,添加export PATH=/path/to/desired/python/bin:$PATH (當然,使用適當的替代方法

  2. 修改bash腳本以顯式聲明python的路徑,從而完全避免使用$PATH

  3. 刪除python的顯式調用,並更改python腳本中的sha-bang以選擇適當的版本。 (還要確保python腳本被標記為可執行)。

您需要將${buildout:executable}的值替換為模板。 我不確定您如何使用buildout_script配方(也許是%(executable)s來引用它?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM