So I am trying to switch from using Jupyter notebook in the browser to using IPython shell in terminal as I prefer it. I am on Ubuntu 22.0.4 OS and when I activate IPython, I can write code and a script but cannot open one or save one.
When I try to run a script that I have created using a Jupyter notebook by using line magic %run I get the following errors:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[6], line 1
----> 1 get_ipython().run_line_magic('run', 'script1.ipynb')
File ~/.local/lib/python3.10/site-packages/IPython/core/interactiveshell.py:2369, in InteractiveShell.run_line_magic(self, magic_name, line, _stack_depth)
2367 kwargs['local_ns'] = self.get_local_scope(stack_depth)
2368 with self.builtin_trap:
-> 2369 result = fn(*args, **kwargs)
2370 return result
File ~/.local/lib/python3.10/site-packages/IPython/core/magics/execution.py:717, in ExecutionMagics.run(self, parameter_s, runner, file_finder)
715 with preserve_keys(self.shell.user_ns, '__file__'):
716 self.shell.user_ns['__file__'] = filename
--> 717 self.shell.safe_execfile_ipy(filename, raise_exceptions=True)
718 return
720 # Control the response to exit() calls made by the script being run
File ~/.local/lib/python3.10/site-packages/IPython/core/interactiveshell.py:2872, in InteractiveShell.safe_execfile_ipy(self, fname, shell_futures, raise_exceptions)
2870 with prepended_to_syspath(dname):
2871 try:
-> 2872 for cell in get_cells():
2873 result = self.run_cell(cell, silent=True, shell_futures=shell_futures)
2874 if raise_exceptions:
File ~/.local/lib/python3.10/site-packages/IPython/core/interactiveshell.py:2860, in InteractiveShell.safe_execfile_ipy.<locals>.get_cells()
2858 """generator for sequence of code blocks to run"""
2859 if fname.suffix == ".ipynb":
-> 2860 from nbformat import read
2861 nb = read(fname, as_version=4)
2862 if not nb.cells:
File ~/.local/lib/python3.10/site-packages/nbformat/__init__.py:11
6 # Copyright (c) IPython Development Team.
7 # Distributed under the terms of the Modified BSD License.
9 from traitlets.log import get_logger
---> 11 from . import v1, v2, v3, v4
12 from ._version import __version__, version_info
13 from .sentinel import Sentinel
File ~/.local/lib/python3.10/site-packages/nbformat/v4/__init__.py:40
37 writes_json = writes
38 to_notebook_json = to_notebook
---> 40 from .convert import downgrade, upgrade
File ~/.local/lib/python3.10/site-packages/nbformat/v4/convert.py:13
9 from traitlets.log import get_logger
11 from nbformat import v3
---> 13 from .. import validator
14 from .nbbase import NotebookNode, nbformat, nbformat_minor, random_cell_id
17 def _warn_if_invalid(nb, version):
File ~/.local/lib/python3.10/site-packages/nbformat/validator.py:16
14 from ._imports import import_item
15 from .corpus.words import generate_corpus_id
---> 16 from .json_compat import ValidationError, _validator_for_name, get_current_validator
17 from .reader import get_version
18 from .warnings import DuplicateCellId, MissingIDFieldWarning
File ~/.local/lib/python3.10/site-packages/nbformat/json_compat.py:11
8 import os
10 import fastjsonschema
---> 11 import jsonschema
12 from fastjsonschema import JsonSchemaException as _JsonSchemaException
13 from jsonschema import Draft4Validator as _JsonSchemaValidator
File ~/.local/lib/python3.10/site-packages/jsonschema/__init__.py:13
1 """
2 An implementation of JSON Schema for Python
3
(...)
9 for you.
10 """
11 import warnings
---> 13 from jsonschema._format import FormatChecker
14 from jsonschema._types import TypeChecker
15 from jsonschema.exceptions import (
16 ErrorTree,
17 FormatError,
(...)
20 ValidationError,
21 )
File ~/.local/lib/python3.10/site-packages/jsonschema/_format.py:11
8 import typing
9 import warnings
---> 11 from jsonschema.exceptions import FormatError
13 _FormatCheckCallable = typing.Callable[[object], bool]
14 _F = typing.TypeVar("_F", bound=_FormatCheckCallable)
File ~/.local/lib/python3.10/site-packages/jsonschema/exceptions.py:12
9 import heapq
10 import itertools
---> 12 import attr
14 from jsonschema import _utils
16 WEAK_MATCHES: frozenset[str] = frozenset(["anyOf", "oneOf"])
ModuleNotFoundError: No module named 'attr'
I have no issue running the script in a Jupyter notebook. Any help would be appreciated.