2013-01-24 42 views

回答

5

使用基於distutils的安裝腳本,然後使用pipeasy_install進行安裝。

您可以指定requests的依賴,它會連同您的腳本安裝這樣:

from distutils.core import setup 

setup(
    # various package metadata fields 

    install_requires=[ 
     'requests', 
    ], 
) 

Declaring DependenciesPython Packaging User Guide以獲取更多信息。

如果因任何原因,你不能使用這個基礎設施,只要解壓縮包requests你的腳本旁邊,和你的腳本的父目錄添加到sys.path

import sys 
import os 

parentdir = os.path.dirname(os.path.abspath(__file__)) 
sys.path.insert(0, parentdir) 

# rest of your imports go here 
import requests 
+0

感謝。任何Python工具都不適合這個,因爲Python腳本是phpFox的「插件」的一部分。因此請求必須一起打包在插件中。有沒有辦法在自己的文件夾中有請求,並從那裏引用它? – dotancohen

+0

爲了其他目的,您提到的鏈接非常棒,我會進一步審覈它們。 – dotancohen

+0

@dotancohen:在那裏,增加了臨時措施。 :-) –