rossant / ipycache

Defines a %%cache cell magic in the IPython notebook to cache results of long-lasting computations in a persistent pickle file
BSD 3-Clause "New" or "Revised" License
138 stars 35 forks source link

module 'IPython.utils.io' has no attribute 'stdout' #74

Open AmineMahdioui opened 2 years ago

AmineMahdioui commented 2 years ago

I just installed this package and tried to use it and got this error: I did use %load_ext ipycachein a previous cell

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In [37], line 1
----> 1 get_ipython().run_cell_magic('cache', "'myvars.pkl' a b c", '\ndatalist=[]\nfor path in os.listdir(\'data/\'):\n    datalist.append(pd.read_excel(\'data/\'+path,decimal=","))\ndata=pd.concat(datalist).set_index(["N_FACTURE","N_LIGNES"])\n\n# data.dtypes==object\n# data.select_dtypes(include=[object])\ndata.head(5)\n')

File c:\Users\amine\OneDrive\Documents\Project\.venv\lib\site-packages\IPython\core\interactiveshell.py:2362, in InteractiveShell.run_cell_magic(self, magic_name, line, cell)
   2360 with self.builtin_trap:
   2361     args = (magic_arg_s, cell)
-> 2362     result = fn(*args, **kwargs)
   2363 return result

File c:\Users\amine\OneDrive\Documents\Project\.venv\lib\site-packages\ipycache.py:396, in CacheMagics.cache(self, line, cell)
    394             pass
    395     path = os.path.join(cachedir, path)
--> 396 cache(cell, path, vars=vars,
    397       force=args.force, verbose=not args.silent, read=args.read,
    398       # IPython methods
    399       ip_user_ns=ip.user_ns,
    400       ip_run_cell=ip.run_cell,
    401       ip_push=ip.push,
    402       ip_clear_output=clear_output
    403       )

File c:\Users\amine\OneDrive\Documents\Project\.venv\lib\site-packages\ipycache.py:265, in cache(cell, path, vars, ip_user_ns, ip_run_cell, ip_push, ip_clear_output, force, read, verbose)
    261 cell_md5 = hashlib.md5(cell.encode()).hexdigest()
    263 if do_save(path, force=force, read=read):
    264     # Capture the outputs of the cell.
--> 265     with capture_output_and_print() as io:
    266         try:
    267             ip_run_cell(cell)

File c:\Users\amine\OneDrive\Documents\Project\.venv\lib\site-packages\ipycache.py:228, in capture_output_and_print.__enter__(self)
    225 stdout = stderr = outputs = None
    226 if self.stdout:
    227     #stdout = sys.stdout = StringIO()
--> 228     stdout = sys.stdout = myStringIO(out=IPython.utils.io.stdout)
    229 if self.stderr:
    230     #stderr = sys.stderr = StringIO()
    231     stderr = sys.stderr = myStringIO(out=self.sys_stderr)

AttributeError: module 'IPython.utils.io' has no attribute 'stdout'