Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
M1cR0xf7 opened this issue Aug 9, 2018 · 17 comments
Closed

Comments

@M1cR0xf7
Copy link

M1cR0xf7 commented Aug 9, 2018

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

@takluyver
Copy link
Member

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.

@ciri
Copy link

ciri commented Sep 5, 2018

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

@idantene
Copy link

idantene commented Sep 5, 2018

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

@MaxSchambach
Copy link

MaxSchambach commented Oct 10, 2018

The fix is merged and should be released with Python 3.7.1 (python/cpython@a410f9f)

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

@Nicholas-Autio-Mitchell

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!

@MaxSchambach
Copy link

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.

@michael-erasmus
Copy link

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?

@MaxSchambach
Copy link

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.

@dartdog
Copy link

dartdog commented Oct 24, 2018

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?

@Nicholas-Autio-Mitchell
Copy link

@amogorkon
Copy link

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.

@Nicholas-Autio-Mitchell

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)

@dartdog
Copy link

dartdog commented Oct 26, 2018

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..

@MaxSchambach
Copy link

MaxSchambach commented Oct 26, 2018

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

@Nicholas-Autio-Mitchell
Copy link

Nicholas-Autio-Mitchell commented Oct 26, 2018 via email

@zacharymostowsky
Copy link

zacharymostowsky commented Dec 5, 2018

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.

@MaxSchambach
Copy link

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests