Notebook: TypeError: register() takes from 2 to 3 positional arguments but 4 were given

Created on 9 Aug 2018  Â·  17Comments  Â·  Source: jupyter/notebook

when opening jupyter notebook it shows this error

jupyter notebook
[I 11:56:10.168 NotebookApp] Serving notebooks from local directory: /home/malsym
[I 11:56:10.168 NotebookApp] 0 active kernels
[I 11:56:10.168 NotebookApp] The Jupyter Notebook is running at:
[I 11:56:10.168 NotebookApp] http://localhost:8888/?token=d789fe23acf854272ed5c9977d[XXXXXXXX]07d4c863f16d33
[I 11:56:10.168 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Traceback (most recent call last):
  File "/usr/bin/jupyter-notebook", line 11, in <module>
    load_entry_point('notebook==5.3.0', 'console_scripts', 'jupyter-notebook')()
  File "/usr/lib/python3.7/site-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/lib/python3.7/site-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/usr/lib/python3.7/site-packages/notebook/notebookapp.py", line 1597, in start
    browser = webbrowser.get(self.browser or None)
  File "/usr/lib/python3.7/webbrowser.py", line 42, in get
    register_standard_browsers()
  File "/usr/lib/python3.7/webbrowser.py", line 567, in register_standard_browsers
    cmd = _synthesize(cmdline, -1)
  File "/usr/lib/python3.7/webbrowser.py", line 116, in _synthesize
    register(browser, None, controller, update_tryorder)
TypeError: register() takes from 2 to 3 positional arguments but 4 were given

my system information

os: arch linux
Kernel Information: Linux 4.17.12-arch1-1-ARCH x86_64
python version: Python 3.7.0
jupyter version: 4.4.0

Most helpful comment

Both jupyter notebook and jupyter-lab have this problem. As @takluyver suggest doing "unset BROWSER" in terminal first fixes the problem:

$ unset BROWSER
$ jupyter notebook

All 17 comments

Looks like this is a bug in Python itself: https://bugs.python.org/issue31014

It sounds like it depends on the BROWSER environment variable; you might be able to work around it by unsetting that. Hopefully it will be fixed in 3.7.1.

Both jupyter notebook and jupyter-lab have this problem. As @takluyver suggest doing "unset BROWSER" in terminal first fixes the problem:

$ unset BROWSER
$ jupyter notebook

@ciri @takluyver That works for me as well (python 3.7, ipython 6.5, jupyter 4.4, arch linux)

The fix is merged and should be released with Python 3.7.1 (https://github.com/python/cpython/commit/a410f9f614b62cd7df220186d081ffd73786be91)

Would it make sense to include this in the dependencies, i.e. that Jupyter Notebook is not compatible with Python 3.7.0?

If the above doesn't work for you, try the following:

Given the error message, we are looking at line 116 of webbrowser.py. There I changed this:

register(browser, None, controller, update_tryorder)

to this:

register(browser, None, controller, preferred=update_tryorder)

Now running jupyter notebook works as expected!

Don't get me wrong, the fix does work. But any user with Python 3.7.0 will find the Notebook and/or Jupyter (Lab) not working but not every user will look around Github for an open/closed issue. I think, this makes the Jupyter Notebook not compatible with Python 3.7.0 and that should hence be mentioned in the dependencies.

Agreed with @MaxSchambach, this is straight up not working on Python 3.7.0. Perhaps you could just apply @Nicholas-Mitchell's fix in the interim rather than leaving all users on 3.7 in a lurch?

Perhaps you could just apply @Nicholas-Mitchell's fix in the interim rather than leaving all users on 3.7 in a lurch?

The meantioned fix is changing the webbrowser.py file, which is not part of Notebook but of the standard Python Library so this is not an option.

From the above I thought I could "fix" the issue by doing for my base anaconda installation. (which is python 3.7)

conda install python=3.7.1
but I got

Solving environment: failed UnsatisfiableError: The following specifications were found to be in conflict: - anaconda-project -> anaconda-client -> python[version='>=2.7,<2.8.0a0'] -> openssl=1.0 - python=3.7.1 Use "conda info <package>" to see the dependencies for each package.

Suggestions?

It looks like you installed Python2 in your base Anaconda/Miniconda
installation.

Try looking at virtual environments!

On Wed, 24 Oct 2018 at 19:20, Tom Brander notifications@github.com wrote:

From the above I thought I could "fix" the issue by doing for my base
anaconda installation.

conda install python=3.7.1
but I got

Solving environment: failed UnsatisfiableError: The following
specifications were found to be in conflict: - anaconda-project ->
anaconda-client -> python[version='>=2.7,<2.8.0a0'] -> openssl=1.0 -
python=3.7.1 Use "conda info " to see the dependencies for each
package.

Suggestions?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/jupyter/notebook/issues/3840#issuecomment-432749827,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMOhpaR79jeo_YCa6DmYZeGkAdLADCOaks5uoKFagaJpZM4V1aDj
.

You can simply put
del os.environ["BROWSER"]
at the top of the ~/anaconda3/lib/python3.7/webbrowser.py as a workaround. That worked for me.

You can simply put
del os.environ["BROWSER"]
at the top of the ~/anaconda3/lib/python3.7/webbrowser.py as a workaround. That worked for me.

This would essentially be the same as the originally proposed solution, which didn't work for me. (but I haven't tested your variant)

Hmmm.... If I type python at the command prompt I get python 3.7.0 but I see what you mean with the dependency message, indicating python 2.7... which simply confuses me more..

I have the same problem in a clean Python 3.7 conda environment. As Python 3.7.1 has just been released, I think it will take a little while for the conda branches to update. In principle, using conda update -n envname python should update Python in the Python branch of the environment, i.e. in the Python 3.7 branch from 3.7.0 to 3.7.1.

But this has nothing to do with the actual issue here. That is, Jupyter notebook not being compatible with Python 3.7.0 due to the bug in webbrowser.py

You currently cannot create a Conda environment with python 3.7.1 along
with Jupyter. If you try, it will fail or attempt to downgrade your python
to 2.7 😂

On Fri, 26 Oct 2018, 17:31 Maximilian Schambach, notifications@github.com
wrote:

I have the same problem in a clean Python 3.7 conda environment. As Python
3.7.1 has just been released, I think it will take a little while for the
conda branches to update. In principle, using conda update -n envname
python should update Python in the Python branch of the environment, i.e.
in the Python 3.7 branch from 3.7.0 to 3.7.1.

But this has nothing to do with the actual issue here. That is, Jupyter
notebook not being compatible with Python 3.7 due to the bug in
webbrowser.py

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/jupyter/notebook/issues/3840#issuecomment-433448598,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMOhpZ6C6Lou-sV7ZYsR4BLbXArb_fy1ks5uoyrrgaJpZM4V1aDj
.

Has there been any update on this? @Nicholas-Mitchell I tried your fix but no help. Am using Anaconda, Python 3.7, Ubuntu 16.04. Thanks, Zach.

I was able to create a new conda env with Python 3.7.1 and Jupyter so that seems to be resolved.

Was this page helpful?
0 / 5 - 0 ratings