2

I am new to Jupyter notebooks and I wanted to have a tool for automatic autocompletion of the code and to have a variable explorer like in Spyder. I found 2 Stackoverflow pages (Autocompletion in Juypter, Variable Explorer in Jupyter) recommending to use the jupyter_contrib_nbextensions.

I did exactly what is written in those posts for Anaconda and I could install the 'jupyter_contrib_nbextensions'. I also installed the 'hinterland' and 'varInspector' extension and I can see the extensions in Jupyter notebooks and activated them (see screenshot)Jupyter_Screenshot. However, I just can't use it. Somehow nothing has changed when I code in Pupyter. Do I have to activate somehting further?

One problem that comes up during activation using the terminal of Anaconda is that I get an message that I do not understand. You can see that in the screenshot. Maybe this has something to do with my difficulties using those extension (but maybe not) Terminal_screensot.

Does anyone have an idea what I have to do in order to use those extensions? I'd appreciate every comment and would be quite thankful for your help.

Do I have to somehow activate it at another position (e.g. directly in the notebook)? Any ideas what the warnings/error messages in the cmd mean?

Reminder on bounty: As I have not received a solution for my answer and my bounty is soon to expire, I'd like to remind you on this quesiton. Does anybody have (further) ideas what the problem might be and how to tackle it? I'd highly appreciate any further idea.

PeterBe
  • 700
  • 1
  • 17
  • 37

2 Answers2

2

Try these:

$ pip install nb_xxx_extension
$ jupyter nb_xxx_extension enable --sys-prefix

You could use conda to install if the extension is available. Otherwise just install pip in your conda env and install as above.

Gordon Bai
  • 483
  • 5
  • 5
  • Thanks Gordon for your answer. Can I use also pip with conda? Basically I have never used pip before. How can I use pip? Shall I just use your suggested code in the conda terminal? – PeterBe Mar 10 '21 at 10:58
  • It can be installed with `conda install pip`, or `conda install -c conda-forge pip` if you want to use the conda-forge channel. Then you can use `pip install xxx_package` in your conda env. There are many scenarios where a specific package is available only in pip not conda or vice versa. – Gordon Bai Mar 10 '21 at 11:03
  • Thanks Gordon for your answer. I did what you said and installed pip and used pip to install 'jupyter_contrib_nbextensions'. The installation was okay. However, still in jupyter notebooks nothing has changed. I still don't have autocomletion and a variable explorer. Bascially I assume it is not a matter of installation because - as you can see in the screenshot of my question - the extensions are listed in jupyter notebooks. – PeterBe Mar 10 '21 at 13:18
  • The problem is although installation finished, it's not installed correctly. Similar problem is this: https://github.com/Jupyter-contrib/jupyter_nbextensions_configurator/issues/37 . You could investigate towards a same direction. – Gordon Bai Mar 10 '21 at 13:23
  • Thanks Gordon for your answer. Do you have any other idea what I can try to use those extensions? – PeterBe Mar 11 '21 at 16:36
  • Any further ideas? – PeterBe Mar 12 '21 at 16:48
  • Might this be a bug in Anaconda? I have the impression that Anaconda is full of bugs and the software quality of Anaconda is generally bad. – PeterBe Mar 15 '21 at 09:12
  • Thanks Gordon for your comments and effort. I really appreciate it. Can you think about another possible cause because your suggested approach unfortunately did not solve the problem. – PeterBe Mar 15 '21 at 09:13
  • The best I can recommend is opening an issue in https://github.com/jupyter/notebook/issues addressing your question. The developer group is far more knowlegeable than a user like me, you could potentially get your answer there :) – Gordon Bai Mar 15 '21 at 12:36
  • Thanks for your answer Gordon. I really appreciate your effort – PeterBe Mar 15 '21 at 13:49
2

It's possible something is messed up in your environment so I would recommend starting afresh in a new environment with a recent version of python (I don't know what version you're using) and start off with just one extension. The below works for me on mac/linux:

conda create -n testenv python=3.8
conda activate testenv
pip install notebook jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
jupyter nbextension enable hinterland/hinterland

You may need to do this in 'Anaconda Prompt' rather than the regular Windows terminal. Finally run jupyter notebook of course to launch the server and create a new notebook to test everything works. If it still isn't working, something else must be really messed up with your environment or it's a bug on windows in which case open an issue.

amin_nejad
  • 989
  • 10
  • 22
  • Thanks amin for your answer. I have been experiencing problems with Anaconda environments all the time. Just to create my current environment (with keras) I had to set it up 20 times. So if in fact there is again a problem with my environment, I will not use Anaconda any more. I have the strong impression that Anaconda itself has a very low software quality and is full of bugs. – PeterBe Mar 17 '21 at 07:28
  • What do I have to do to set up a environment in Anaconda with keras and pyomo and to make it not mess up? And why in general does Anaconda mess up the environments all the time? – PeterBe Mar 17 '21 at 07:31
  • I upvoted your answer and awarded the bounty to you as I think that you are right with the messed up environment. I hope you can still give me some advice as how to use Anaconda without messing up environment – PeterBe Mar 17 '21 at 07:32
  • I don't think the problem is necessarily Anaconda, I actually use it for my environments regularly without problems. But things are often more tricky on Windows, I haven't used it in a few years but I would often have problems too. As I said I think the above code should work but if not, you may have a wrong version of some software outside of your conda environment or something like that. Generally speaking, if you are able to use [WSL](https://docs.microsoft.com/en-us/windows/wsl/install-win10) instead of Windows for your python/software development, I would strongly recommend that. – amin_nejad Mar 17 '21 at 13:27
  • Thanks amin for your answer. Basically I would not like to use Linux only for Python as I do not have any other application for Linux. I would rather not use Anaconda anymore because I have been having many problems with it (for me the tool that by farcreated the most issues that I have every used for coding). Do you know any other alternative to Anaconda? Or can I just install jupyter notebook and Spyder individually and combine their package management? – PeterBe Mar 17 '21 at 14:13
  • No worries, you can just use the built-in python virtual environment manager [`venv`](https://docs.python.org/3/tutorial/venv.html) instead of `conda` and just use `pip` as before for installing packages. That should work fine. – amin_nejad Mar 17 '21 at 17:28
  • Thanks amin for your answer. Would you then delete Anaconda or can I use the two package managers in parallel? – PeterBe Mar 19 '21 at 08:10
  • They can be used in parallel – amin_nejad Mar 19 '21 at 11:38