【问题标题】:How to set a Python path so that modules are found?如何设置 Python 路径以便找到模块?
【发布时间】:2013-08-06 23:31:12
【问题描述】:

我正在尝试运行我的 boto 脚本,但出现以下错误:

ImportError: No module named boto.swf.layer2

根据 pip freeze 我已经安装了 boto,所以我想知道这里出了什么问题。

我的Python路径如下:

['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']

我的boto路径如下:

/usr/lib/python2.7/dist-packages/boto/__init__.pyc

这是否意味着与 Python 路径有关的某种错误?我真的不知道如何调试它。

【问题讨论】:

  • 看起来不是路径问题,而是缺少模块或模块名称错误。

标签: python linux amazon-web-services pip boto


【解决方案1】:

首先我要验证你至少可以导入 boto:

import boto
print boto.__file__

验证它在/usr/lib/python2.7/dist-packages/boto/__init__.pyc 中。

如果可行,那么我会检查您的 boto 版本:

import boto
print boto.__version__

您尝试导入的特定模块已在 2.7.0 中添加到 boto,因此您至少需要该版本。

【讨论】:

    猜你喜欢
    • 2012-12-12
    • 2011-08-15
    • 2019-10-21
    • 1970-01-01
    • 1970-01-01
    • 2015-08-31
    • 1970-01-01
    • 2018-08-24
    • 1970-01-01
    相关资源
    最近更新 更多