我有一个'无法导入名称StringIO'导入dateutil
时尝试导入StringIO
但无法找到错误消息。这是完整的跟踪:
(DEV)arbi@el-oued:~/Work/sentimentpy$ python core/main.py
Traceback (most recent call last):
File "core/main.py", line 7, in <module>
from io.reader import *
File "/home/arbi/Work/sentimentpy/core/io/reader.py", line 4, in <module>
from dateutil import parser
File "/home/arbi/DEV/local/lib/python2.7/site-packages/dateutil/parser.py", line 22, in <module>
from io import StringIO
ImportError: cannot import name StringIO
当我尝试使用python3
启动程序时,我遇到了这个错误:
(DEV)arbi@el-oued:~/Work/sentimentpy$ python3 core/main.py
Traceback (most recent call last):
File "core/main.py", line 1, in <module>
from analyzer.length import LengthAnalyzer
File "/home/arbi/Work/sentimentpy/core/analyzer/length.py", line 4, in <module>
from numpy
ImportError: No module named numpy
为什么我有这个?我在我的virtualenv中使用numpy
pip install numpy
答案 0 :(得分:3)
您正在屏蔽内置io
模块,因为您的项目中有一个名为io
的包:
Traceback (most recent call last):
File "core/main.py", line 7, in <module>
from io.reader import *
File "/home/arbi/Work/sentimentpy/core/io/reader.py", line 4, in <module>
第from io import StringIO
行找到/home/arbi/Work/sentimentpy/core/io
,不内置模块。
重命名该包或将其移动到不冲突的新顶级包名称中。
你的第二个错误是无关的;你根本没有为Python 3安装numpy
。