Hello all,
I have been having trouble with my Jupyter notebook recently. First of all the Python3 kernel no longer shows up when I try to create a new file. On top of that, all my .ipynb files on Github are unable to be opened because it says Invalid Notebook – The Notebook Does Not Appear to Be Valid JSON. When I try to re-install a Python3 kernel on my terminal I get another error, “attempted relative import with no known parent package”. Something clearly has gone very wrong. I have attached photos. Thank you in advance to anyone who can help me get this back running again.
Do you know what changed around the times things stopped working? For example, did you upgrade your MacOS and then it stopped working?
Fortunately, it looks like you installed Anaconda. I’d stick with working in conda then.
In the image, you are working in the base conda environment.
Are you still able to activate other environments you made and run notebooks there?
Are you able to run conda list
when in your environments like shown here.
If you run which python
is it using the Python installed by Anaconda?
Not advising this yet, however, depending on how much you want to invest in sorting out issues on your system, you may want to start to consider this…
How many environments and things have you made? If not many, it may just be easier to start over by uninstalling Anaconda and re-installing following the most current instructions from Anaconda. It looks like you had Python 3.8 on there so and so the default stuff is already like 2 years old. Plus, depending on your MacOX you may be better off with a graphical installation now because I note it says here:
“Unlike the graphical install, installing the shell file will place it in ~/anaconda<2 or 3> by default, not ~/opt. This is due to limitations with installing .pkg files on macOS Catalina.”
Hi fomightez, Thank you very much for the reply. The bug started around the time I started using VSCode. I am going to try deleting Anaconda completely from my mac and reinstall. I have all my code saved in other places on my computer so it shouldn’t delete anything important.
Also not that the stock Anaconda Distribution and miniconda
both use anaconda.com
as their default package source: depending upon whose behalf you are working, this may be a violation of the terms of service. Additionally, those packages (and anaconda.org/anaconda
) usually lag behind the upstreams by up to a quarter.
The upstream in question, in this case, is conda-forge
, which is distributed from anaconda.org/conda-forge
. Most of the jupyter-related packages are maintained by the same folk that write the software, and actively try to keep even historical versions working correctly.
You can use a non-encumbered base
environment from GitHub - conda-forge/miniforge: A conda-forge distribution. (pretty download page), including Mambaforge
, which provides the speedier, more robust, and generally more helpful-when-failing mamba
CLI, a drop-in replacement for conda
. Keeping this environment small, and up-to-date, helps ensure your interactive computing doesn’t break your interactive package management.
Finally: however you install your base
environment, it is recommended to build up your jupyter environment(s) outside of that base
, ideally starting with an environment.yml
that provides at least some sanity pins, a la:
name:
- my-jupyter-env
channels:
- conda-forge
dependencies:
- python >=3.10,<3.11
- jupyterlab >=4.0.5,<5
- notebook >=7,<8
# etc...
And then:
mamba env update --file environment.yml --name my-jupyter-env
While the two arguments are optional, it’s a good habit to be explicit.