【问题标题】:python module installed and recognized, but unable to import it on my code or python 2.7.1 interpreter on Ubuntupython 模块已安装并识别,但无法在我的代码或 Ubuntu 上的 python 2.7.1 解释器上导入它
【发布时间】:2011-08-12 21:11:04
【问题描述】:

我一直在尝试启动并运行 python C 模块。我正在从Here 安装 deltaLDA 模块。我按照 REAMDE 文件中指定的说明进行操作。像往常一样,我写道:

sudo python setup.py install

我猜一切都按预期进行,我得到了这个输出:

    running build
    running build_ext
    building 'deltaLDA' extension
    C compiler: gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC

    creating build
    creating build/temp.linux-i686-2.7
    compile options: '-I/media/Hub/DropBox/Dropbox/Betazeta/Software/LDA/deltaLDA -I/usr/lib/pymodules/python2.7/numpy/core/include -I/usr/include/python2.7 -c'
    extra options: '-O3 -Wall'
    gcc: deltaLDA.c
    In file included from /usr/include/python2.7/Python.h:8:0,
                     from deltaLDA.c:22:
    /usr/include/python2.7/pyconfig.h:1155:0: warning: "_POSIX_C_SOURCE" redefined
    /usr/include/features.h:214:0: note: this is the location of the previous definition
    deltaLDA.c:686:1: warning: function declaration isn’t a prototype
    creating build/lib.linux-i686-2.7
    gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions build/temp.linux-i686-2.7/deltaLDA.o -o build/lib.linux-i686-2.7/deltaLDA.so
    running install_lib
    copying build/lib.linux-i686-2.7/deltaLDA.so -> /usr/local/lib/python2.7/dist-packages
    running install_egg_info
    Removing /usr/local/lib/python2.7/dist-packages/deltaLDA-0.1.1.egg-info
    Writing /usr/local/lib/python2.7/dist-packages/deltaLDA-0.1.1.egg-info

但是当我尝试导入 deltaLDA 模块时,我收到以下错误:

>>> from deltaLDA import deltaLDA
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named deltaLDA

如果我使用 help('modules') 或 pip freeze 命令检查已安装的模块,我可以在两个列表中找到 deltaLDA,但我无法导入它。请提供任何帮助。

谢谢!

更新: 我还验证了 sys.path 和 '/usr/local/lib/python2.7/dist-packages' 它就在上面。如果我尝试从 from deltaLDA import * 之类的 deltaLDA 导入 *,我会遇到同样的错误。在解释器上也尝试dir(deltaLDA) 得到相同的“无模块名称”错误。也许 deltaLDA 模块有问题?有人可以尝试安装吗?

已修复

我检查了 dist 包上 .so 和 egg-info 文件的权限。它们不可读,我不知道为什么。我刚刚运行了一个 sudo chmod 777 文件,现在它可以工作了!

【问题讨论】:

  • /usr/local/lib/python2.7/dist-packagessys.path 中吗?
  • from deltaLDA import deltaLDA 暗示在 deltaLDA 模块中有一个名为 deltaLDA 的模块/类/方法。检查模块文档,看看是否是这种情况。您也可以通过 python 解释器执行 dir(deltaLDA) 来查看它定义的所有内容。

标签: python module installation lda


【解决方案1】:

第一次尝试

>>> import deltaLDA

如果可行,请查看文档或查看@arunkumar 所说的 dir(deltaLDA),如果没有发布您的 sys.path,请查看您的 egg-info 详细信息

【讨论】:

    猜你喜欢
    • 2018-04-23
    • 2021-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-09-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多