No Module Named StringIO
Solution 1:
I think you're looking for the io module in Python 3.x. cStringIO
(which is a Python 2 module that is a faster version of StringIO
, see here) was replaced with io
, along with a host of other changes. See here for more info about that.
Historical note: Here is the reason why we no longer have both cStringIO
and StringIO
:
A common pattern in Python 2.x is to have one version of a module implemented in pure Python, with an optional accelerated version implemented as a C extension; for example, pickle and cPickle. This places the burden of importing the accelerated version and falling back on the pure Python version on each user of these modules. In Python 3.0, the accelerated versions are considered implementation details of the pure Python versions. Users should always import the standard version, which attempts to import the accelerated version and falls back to the pure Python version. The pickle / cPickle pair received this treatment. The profile module is on the list for 3.1. The StringIO module has been turned into a class in the io module. (Source)
Solution 2:
Use this one:
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
Post a Comment for "No Module Named StringIO"