Skip to content

[Solved][Python] ModuleNotFoundError: No module named ‘cStringIO’

Last Updated on 2020-10-20 by Clay

python
Display Python code on the screen

Introduction

This is a record of the error message that I have encountered: When learning a sample code provided on the Internet, it was no problem for them to use the code to cut the picture and save it in the clipboard, but when I used their sample, it show the following error message:

ModuleNotFoundError: No module named 'cStringIO'

It looks like I lacked the cStringIO module, and finally I found the answer on StackOverflow.

The following simple record solution.


Solution

This problem is usually encountered when using the following code:

from cStringIO import StringIO


Output:

ModuleNotFoundError: No module named 'cStringIO'

The reason is actually very simple. The cString module is only available in Python 2.x. In Python 3.x, if you want to use StringIO, BytesIO and other modules, we can directly import io.

For example

from io import StringIO

You can try to confirm whether it can be executed normally


References


Read More

Leave a Reply