any*_*ny1 14 python import packages igraph
当我在项目中导入igraph包时,我得到一个AttributeError.这只发生在项目目录中:
[12:34][~]$ python2
Python 2.7.1 (r271:86832, Apr 15 2011, 12:09:10)
[GCC 4.5.2 20110127 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import igraph
>>>
[12:34][~]$ cd projectdir/
[12:34][projectdir]$ python2
Python 2.7.1 (r271:86832, Apr 15 2011, 12:09:10)
[GCC 4.5.2 20110127 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import igraph
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/igraph/__init__.py", line 42, in <module>
import gzip
File "/usr/lib/python2.7/gzip.py", line 36, in <module>
class GzipFile(io.BufferedIOBase):
AttributeError: 'module' object has no attribute 'BufferedIOBase'
>>>
Run Code Online (Sandbox Code Playgroud)
项目目录中没有文件igraph.py:
[12:34][projectdir]$ ls -alR | grep igraph | wc -l
0
Run Code Online (Sandbox Code Playgroud)
而且没有循环进口.
我该如何解决这个错误?
phi*_*hag 31
最有可能的,有一个模块io中~/projectdir或项目配置的路径之一.igraph导入的gzip模块以
import io
Run Code Online (Sandbox Code Playgroud)
并期望内置的io模块,而不是你的项目.查找io目录或io.py或io.pyc.它还可以帮助仔细检查可能包含命名模块的sys.path任何其他目录(可能在其外~/projectdir)io.