Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm having a 'Cannot import name StringIO' error message when importing dateutil which tries to import StringIO but cannot find it. Here is complete trace:

(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

When I tried to use python3 to launch my program, i had this error:

(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

Why I'm having this? i've installed numpy in my virtualenv with: pip install numpy

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
330 views
Welcome To Ask or Share your Answers For Others

1 Answer

You are masking the built-in io module because you have a package named io in your project:

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>

The line from io import StringIO finds /home/arbi/Work/sentimentpy/core/io, not the built-in module.

Rename that package or move it into a new top-level package name that doesn't conflict.

Your second error is unrelated; you simply don't have numpy installed for Python 3.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...