Cannot Run Jupyter Notebook on Terminal

Viewed 465

for my homework we need to use jupyter notebook to run an .ipynb file. I use Mac and I used pip install jupyter to install it using terminal, which was successful. However when I tried to open it using the commandjupter notebook I get this error. Any ideas? Thanks. error

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/bin/jupyter-notebook", line 5, in from notebook.notebookapp import main File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/notebook/notebookapp.py", line 76, in from .base.handlers import Template404, RedirectWithParams File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/notebook/base/handlers.py", line 24, in import prometheus_client File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/init.py", line 3, in from . import ( File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/gc_collector.py", line 43, in GC_COLLECTOR = GCCollector() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/gc_collector.py", line 14, in init registry.register(self) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/registry.py", line 26, in register names = self._get_names(collector) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/registry.py", line 66, in _get_names for metric in desc_func(): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/gc_collector.py", line 36, in collect collected.add_metric([generation], value=stat['collected']) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/metrics_core.py", line 126, in add_metric self.samples.append(Sample(self.name + '_total', dict(zip(self._labelnames, labels)), value, timestamp)) TypeError: new() missing 1 required positional argument: 'exemplar'

2 Answers

From your terminal out screen grab, I can see that you are not in a virtual environment which would mean that you are using global python.

Three things to check and or consider:

1. Python Version (management and checking).

To avoid the type of error that you are seeing- creating dependency issues of your versions of python, it may be an idea to use a package manager like conda or use virtual environments and install within them.

2. Proper use of pip install:

If you do not want to use vnev's or a package manager like conda perhaps double-check that you have installed on the correct version of python and install jupyter on the version of python you want to use.

python3.6 -m pip install jupyter

3. Environment Management:

There are a number of different options for managing the python version some people like to create virtual environments within your present working directory and active them using:

python3.6 -m pip install virtualenv
python3.6 -m venv env_name 
source env_name/bin/activate

Once activated your terminal will show:

(env_name) jeffmpro.... 

You can then pip install jupyter inside this environment and this will then run using:

jupyter notebook

If you want to manage the python version and virtual environments globally using shims you can do this using a package called pyenv:

https://github.com/pyenv/pyenv

https://github.com/pyenv/pyenv-virtualenv

I would also use homebrew on mac to manage installations in the command line.

https://brew.sh/

Hope this helps :-)

The correct answer is actually what came out in the comments, I'll report it here for future viewers:

pip install jupyter
pip install notebook
jupyter-notebook your-file.ipynb

See you!

Related