You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resolved import error 'cannot import name 'BytesType' from 'diskcache.core'' in '/dlwpt-code/p2ch10_explore_data.ipynb' by updating the import statement in 'util/disk.py' .
This is a legacy issue. By inspecting the commit history of the python-diskcache library, you will find that diskcache.core.BytesType was essentially str (in Python 2) or bytes (in Python 3), which was added and then removed.
And diskcache.core.BytesIO is StringIO.cStringIO/StringIO.StringIO (in Python 2) and io.BytesIO (in Python 3).
+if sys.hexversion < 0x03000000:
+ range = xrange
+ try:
+ from cStringIO import StringIO as BytesIO
+ except ImportError:
+ from StringIO import StringIO as BytesIO
+
+else:
+ import io
+ BytesIO = io.BytesIO
Solution
Since we have known what the BytesType and BytesIO should be, let's edit the /util/disk.py directly:
fromdiskcacheimportFanoutCache, Diskfromdiskcache.coreimportMODE_BINARY# delete BytesType and BytesIO declarationsBytesType=bytes# Import them by ourselvesimportioBytesIO=io.BytesIO
The text was updated successfully, but these errors were encountered:
AliSerwat
changed the title
Resolved import error 'cannot import name 'BytesType' from 'diskcache.core'' in '/dlwpt-code/p2ch10_explore_data.ipynb' by updating the import statement in 'util/disk.py' .
Solution for import error: 'cannot import name 'BytesType' from 'diskcache.core''
Jul 4, 2024
AliSerwat
changed the title
Solution for import error: 'cannot import name 'BytesType' from 'diskcache.core''
Solution for import error: "cannot import name 'BytesType' from 'diskcache.core'"
Jul 4, 2024
Resolved import error 'cannot import name 'BytesType' from 'diskcache.core'' in '/dlwpt-code/p2ch10_explore_data.ipynb' by updating the import statement in 'util/disk.py' .
This is a legacy issue. By inspecting the commit history of the python-diskcache library, you will find that
diskcache.core.BytesType
was essentiallystr
(in Python 2) orbytes
(in Python 3), which was added and then removed.And
diskcache.core.BytesIO
isStringIO.cStringIO
/StringIO.StringIO
(in Python 2) andio.BytesIO
(in Python 3).Solution
Since we have known what the
BytesType
andBytesIO
should be, let's edit the/util/disk.py
directly:And that works for me.
Originally posted by @yaner-here in #27 (comment)
The text was updated successfully, but these errors were encountered: