AttributeError: 'module' object has no attribute 'best_partition'
来源:互联网 发布:建筑三维制图软件 编辑:程序博客网 时间:2024/05/21 18:47
问题描述:
在使用louvin算法时,导入该算法包,运行程序时AttributeError: ‘module’ object has no attribute ‘best_partition’错误。
分析:
之前在网上查了很多,没有具体有效的办法。最后就另外写了一个简单的测试文件。发现我只是在外部安装了louvin,在虚拟环境中没有安装,所以重新再虚拟环境中安装就OK。
最重要的是检测当前代码运行环境中,是否安装了louvin。
解决办法:
先激活虚拟环境,安装Louvin.
python setup.py install
但是问题又来了。。。
在系统环境下,是可以直接使用import community。但是在虚拟环境中,虽然显示已经安装成功,但是,必须把.py放在louvain文件夹下才可以使用Import,否则将又出现AttributeError: ‘module’ object has no attribute ‘best_partition’错误。
解决办法:
移动项目文件到louvain文件夹下面。
另外一个猜测的解决办法如下:
查看了虚拟环境安装包的位置:
虚拟环境文件夹/lib/python2.7/site-packages,
在site-packages文件夹下面是虚拟环境安装的很多工具包,我的一个猜想是把其中的community文件夹的增加louvain/commounity/下的py文件。
0 0
- AttributeError: 'module' object has no attribute 'best_partition'
- AttributeError: 'module' object has no attribute 'getpass'
- AttributeError: 'module' object has no attribute 'Serial'
- AttributeError: 'module' object has no attribute(转)
- AttributeError: 'module' object has no attribute 'randint'
- AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'
- AttributeError: 'module' object has no attribute 'Serial'
- AttributeError: 'module' object has no attribute 'LabelMap'
- AttributeError: 'module' object has no attribute 'XXX'
- AttributeError: 'module' object has no attribute 'urlopen'
- AttributeError:'module' object has no attribute 'classify'
- AttributeError: ‘module’ object has no attribute’xxx’
- AttributeError: ‘module’ object has no attribute’ 问题
- AttributeError: 'module' object has no attribute 'VideoWriter_fourcc'
- AttributeError: 'module' object has no attribute 'AF_INET'
- AttributeError: 'module' object has no attribute 'VideoWriter_fourcc'
- AttributeError: 'module' object has no attribute '_base'
- AttributeError: 'module' object has no attribute 'imsave'
- cogs 732. [网络流24题] 试题库
- spring+struts2+mybatis 框架下图片上传
- 在迅捷CAD编辑器中修改文字大小的办法
- nginx反向代理和正向代理
- vuejs安装
- AttributeError: 'module' object has no attribute 'best_partition'
- 七.Git常见问题及知识点补充2
- HDU 4460 Friend Chains 【bfs】【spfa】
- leetcode python
- Hello word!
- spring 注解方式实现aop
- android加密、签名相关
- JavaScript运算符
- ThreadPoolExecutor线程池