gpt4 book ai didi

已安装并识别 python 模块,但无法将其导入我的代码或 Ubuntu 上的 python 2.7.1 解释器

转载 作者:太空宇宙 更新时间:2023-11-04 06:27:10 24 4
gpt4 key购买 nike

我一直在尝试启动并运行 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) 得到相同的“No module name”错误。也许deltaLDA模块有问题?有人可以尝试安装它吗?

固定

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

最佳答案

第一次尝试

>>> import deltaLDA

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

关于已安装并识别 python 模块,但无法将其导入我的代码或 Ubuntu 上的 python 2.7.1 解释器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7046372/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com