【问题标题】:"Vendorize" using setup.py使用 setup.py “供应商”
【发布时间】:2016-01-11 16:06:31
【问题描述】:

我一直将setup.py 用于gspread 之类的软件包,但没有找到setup.py 的详细信息。在我 PC 上的默认 Python 安装上完成后一切正常。

现在我想在 GAE 项目中使用 gspread。它需要“vendorizing”,类似于安装到我的应用程序目录中的lib 文件夹中。如何使用setup.py 指定?

我尝试使用home scheme 并运行:

c:\Python27\python setup.py install --home="D:\Documents\Google Cloud\myapp"

但它说:

running install
Checking .pth file support in D:\Documents\Google Cloud\myapp\lib\python\
c:\Python27\pythonw.exe -E -c pass
TEST FAILED: D:\Documents\Google Cloud\myapp\lib\python\ does NOT support .pth files
error: bad install directory or PYTHONPATH

You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from.  The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    D:\Documents\Google Cloud\myapp\lib\python\

and your PYTHONPATH environment variable currently contains:

    ''

【问题讨论】:

    标签: python setup.py


    【解决方案1】:

    您可以尝试将D:\Documents\Google Cloud\myapp 添加到您的PYTHONPATH 环境变量中。在 Windows 中,您可以进入 Control Panel -> System and Security -> System -> Advanced System Settings -> Environmental Variables 下,然后编辑 PYTHONPATH 系统变量。路径由分号分隔,因此只需将其添加到末尾,C:\Python27\Lib;C:\Python27\DLLs;"D:\Documents\Google Cloud\myapp"

    【讨论】:

    • 我将它添加到 PYTHONPATH 参数中,但它不会安装。如果我指定D:\Documents\Google Cloud\myapp\lib\python,它安装没有错误。添加的所有内容似乎都在...myapp\lib\python 中。但是,当我尝试在我的代码中导入时,它说ImportError: No module named gspread
    • 当然,在您将它安装在非标准位置之后,您需要为 python 添加一个新位置来检查模块。这就是sys.path 的用途,所以只需sys.path.append("D:\Documents\Google Cloud\myapp\lib\python"),然后尝试import gspread。请记住,这只会是当前脚本的本地。
    猜你喜欢
    • 1970-01-01
    • 2013-03-02
    • 2017-03-13
    • 2017-04-27
    • 1970-01-01
    • 2017-02-09
    • 2015-07-17
    • 2014-12-13
    • 1970-01-01
    相关资源
    最近更新 更多