导入dateutil时无法导入名称StringIO

时间:2014-09-20 09:17:17

标签: python numpy virtualenv importerror python-dateutil

我有一个'无法导入名称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

1 个答案:

答案 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