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

AttributeError: 'NoneType' object has no attribute 'isatty': sys.stdin.isatty() #1108

Closed
jpastuszek opened this issue Apr 27, 2017 · 4 comments

Comments

@jpastuszek
Copy link

How to reproduce the issue
500 while trying to log in with default config using anaconda3 installation.

What you expected to happen
Login to work.

What actually happens
500 error with exception logged:

[W 2017-04-27 15:11:18.408 jupyter login:225] All authentication is disabled.  Anyone who can connect to this server will be able to run code.
Traceback (most recent call last):
  File "/anaconda3/bin/jupyterhub-singleuser", line 6, in <module>
    main()
  File "/anaconda3/lib/python3.6/site-packages/jupyterhub/singleuser.py", line 322, in main
    return SingleUserNotebookApp.launch_instance(argv)
  File "/anaconda3/lib/python3.6/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/anaconda3/lib/python3.6/site-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/anaconda3/lib/python3.6/site-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/anaconda3/lib/python3.6/site-packages/notebook/notebookapp.py", line 1298, in initialize
    self.init_signal()
  File "/anaconda3/lib/python3.6/site-packages/notebook/notebookapp.py", line 1168, in init_signal
    if not sys.platform.startswith('win') and sys.stdin.isatty():
AttributeError: 'NoneType' object has no attribute 'isatty'

Share what version of JupyterHub you are using
0.7.2

Running jupyter troubleshoot from the command line, if possible, and posting
its output would also be helpful.

If I comment out 2 lines in notebookapp.py I can log in but then terminal won't work with this error:

[I 2017-04-27 15:13:43.543 JupyterHub log:100] 200 GET /hub/api/authorizations/cookie/jupyter-hub-token-jupyter/[secret] (jupyter@127.0.0.1) 11.32ms
[E 2017-04-27 15:13:47.015 jupyter handlers:527] Unhandled error in API request
    Traceback (most recent call last):
      File "/anaconda3/lib/python3.6/site-packages/notebook/base/handlers.py", line 516, in wrapper
        result = yield gen.maybe_future(method(self, *args, **kwargs))
      File "/anaconda3/lib/python3.6/site-packages/tornado/web.py", line 2897, in wrapper
        return method(self, *args, **kwargs)
      File "/anaconda3/lib/python3.6/site-packages/notebook/terminal/api_handlers.py", line 18, in post
        name, _ = self.terminal_manager.new_named_terminal()
      File "/anaconda3/lib/python3.6/site-packages/terminado/management.py", line 303, in new_named_terminal
        term = self.new_terminal()
      File "/anaconda3/lib/python3.6/site-packages/terminado/management.py", line 161, in new_terminal
        pty = PtyProcessUnicode.spawn(argv, env=env, cwd=options.get('cwd', None))
      File "/anaconda3/lib/python3.6/site-packages/ptyprocess/ptyprocess.py", line 288, in spawn
        inst = cls(pid, fd)
      File "/anaconda3/lib/python3.6/site-packages/ptyprocess/ptyprocess.py", line 790, in __init__
        super(PtyProcessUnicode, self).__init__(pid, fd)
      File "/anaconda3/lib/python3.6/site-packages/ptyprocess/ptyprocess.py", line 153, in __init__
        _make_eof_intr()  # Ensure _EOF and _INTR are calculated
      File "/anaconda3/lib/python3.6/site-packages/ptyprocess/ptyprocess.py", line 64, in _make_eof_intr
        fd = sys.__stdin__.fileno()
    AttributeError: 'NoneType' object has no attribute 'fileno'
$PATH:
	/anaconda3/bin
	/anaconda3/bin
	/anaconda3/bin
	/anaconda3/bin
	/anaconda3/bin
	/usr/local/sbin
	/usr/bin
	/bin
	/usr/sbin
	/sbin
	/root/bin
	/opt/aws/bin
	/usr/local/bins
	/usr/local/bin

sys.path:
	/anaconda3/bin
	/anaconda3/lib/python36.zip
	/anaconda3/lib/python3.6
	/anaconda3/lib/python3.6/lib-dynload
	/anaconda3/lib/python3.6/site-packages
	/anaconda3/lib/python3.6/site-packages/Sphinx-1.5.1-py3.6.egg
	/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg

sys.executable:
	/anaconda3/bin/python

sys.version:
	3.6.1 |Anaconda custom (64-bit)| (default, Mar 22 2017, 19:54:23)
	[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]

platform.platform():
	Linux-4.9.20-11.31.amzn1.x86_64-x86_64-with-glibc2.2.5

which -a jupyter:
	/anaconda3/bin/jupyter
	/anaconda3/bin/jupyter
	/anaconda3/bin/jupyter
	/anaconda3/bin/jupyter
	/anaconda3/bin/jupyter

pip list:
	alabaster (0.7.9)
	alembic (0.9.1)
	anaconda-client (1.6.0)
	anaconda-navigator (1.5)
	anaconda-project (0.4.1)
	astroid (1.4.9)
	astropy (1.3)
	Babel (2.3.4)
	backports.shutil-get-terminal-size (1.0.0)
	beautifulsoup4 (4.5.3)
	bitarray (0.8.1)
	blaze (0.10.1)
	bokeh (0.12.4)
	boto (2.45.0)
	Bottleneck (1.2.0)
	cffi (1.9.1)
	chardet (2.3.0)
	chest (0.2.3)
	click (6.7)
	cloudpickle (0.2.2)
	clyent (1.2.2)
	colorama (0.3.7)
	conda (4.3.16)
	configobj (5.0.6)
	contextlib2 (0.5.4)
	cryptography (1.7.1)
	cycler (0.10.0)
	Cython (0.25.2)
	cytoolz (0.8.2)
	dask (0.13.0)
	datashape (0.5.4)
	decorator (4.0.11)
	dill (0.2.5)
	docutils (0.13.1)
	et-xmlfile (1.0.1)
	fastcache (1.0.2)
	Flask (0.12)
	Flask-Cors (3.0.2)
	gevent (1.2.1)
	greenlet (0.4.11)
	h5py (2.6.0)
	HeapDict (1.0.0)
	idna (2.2)
	imagesize (0.7.1)
	ipykernel (4.5.2)
	ipython (5.1.0)
	ipython-genutils (0.2.0)
	ipywidgets (5.2.2)
	isort (4.2.5)
	itsdangerous (0.24)
	jdcal (1.3)
	jedi (0.9.0)
	Jinja2 (2.9.6)
	jsonschema (2.5.1)
	jupyter (1.0.0)
	jupyter-client (4.4.0)
	jupyter-console (5.0.0)
	jupyter-core (4.2.1)
	jupyterhub (0.7.2)
	lazy-object-proxy (1.2.2)
	llvmlite (0.15.0)
	locket (0.2.0)
	lxml (3.7.2)
	Mako (1.0.6)
	MarkupSafe (1.0)
	matplotlib (2.0.0)
	mistune (0.7.3)
	mpmath (0.19)
	multipledispatch (0.4.9)
	nbconvert (4.2.0)
	nbformat (4.2.0)
	networkx (1.11)
	nltk (3.2.2)
	nose (1.3.7)
	notebook (5.0.0)
	numba (0.30.1)
	numexpr (2.6.1)
	numpy (1.11.3)
	numpydoc (0.6.0)
	odo (0.5.0)
	openpyxl (2.4.1)
	pamela (0.3.0)
	pandas (0.19.2)
	partd (0.3.7)
	pathlib2 (2.2.0)
	patsy (0.4.1)
	pep8 (1.7.0)
	pexpect (4.2.1)
	pickleshare (0.7.4)
	Pillow (4.0.0)
	pip (9.0.1)
	ply (3.9)
	prompt-toolkit (1.0.9)
	psutil (5.0.1)
	ptyprocess (0.5.1)
	py (1.4.32)
	pyasn1 (0.1.9)
	pycosat (0.6.1)
	pycparser (2.17)
	pycrypto (2.6.1)
	pycurl (7.43.0)
	pyflakes (1.5.0)
	Pygments (2.1.3)
	pylint (1.6.4)
	pyOpenSSL (16.2.0)
	pyparsing (2.1.4)
	pytest (3.0.5)
	python-dateutil (2.6.0)
	python-editor (1.0.3)
	pytz (2016.10)
	PyYAML (3.12)
	pyzmq (16.0.2)
	QtAwesome (0.4.3)
	qtconsole (4.2.1)
	QtPy (1.2.1)
	redis (2.10.5)
	requests (2.13.0)
	rope-py3k (0.9.4.post1)
	scikit-image (0.12.3)
	scikit-learn (0.18.1)
	scipy (0.18.1)
	seaborn (0.7.1)
	setuptools (27.2.0)
	simplegeneric (0.8.1)
	singledispatch (3.4.0.3)
	six (1.10.0)
	snowballstemmer (1.2.1)
	sockjs-tornado (1.0.3)
	Sphinx (1.5.1)
	spyder (3.1.2)
	SQLAlchemy (1.1.9)
	statsmodels (0.6.1)
	sympy (1.0)
	tables (3.3.0)
	terminado (0.6)
	toolz (0.8.2)
	tornado (4.5.1)
	traitlets (4.3.2)
	unicodecsv (0.14.1)
	wcwidth (0.1.7)
	Werkzeug (0.11.15)
	wheel (0.29.0)
	widgetsnbextension (1.2.6)
	wrapt (1.10.8)
	xlrd (1.0.0)
	XlsxWriter (0.9.6)
	xlwt (1.2.0)

conda list:
	# packages in environment at /anaconda3:
	#
	_license                  1.1                      py36_1
	alabaster                 0.7.9                    py36_0
	alembic                   0.9.1                     <pip>
	anaconda                  custom                   py36_0
	anaconda-client           1.6.0                    py36_0
	anaconda-navigator        1.5.0                    py36_0
	anaconda-project          0.4.1                    py36_0
	astroid                   1.4.9                    py36_0
	astropy                   1.3                 np111py36_0
	babel                     2.3.4                    py36_0
	backports                 1.0                      py36_0
	beautifulsoup4            4.5.3                    py36_0
	bitarray                  0.8.1                    py36_0
	blaze                     0.10.1                   py36_0
	bokeh                     0.12.4                   py36_0
	boto                      2.45.0                   py36_0
	bottleneck                1.2.0               np111py36_0
	cairo                     1.14.8                        0
	cffi                      1.9.1                    py36_0
	chardet                   2.3.0                    py36_0
	chest                     0.2.3                    py36_0
	click                     6.7                      py36_0
	cloudpickle               0.2.2                    py36_0
	clyent                    1.2.2                    py36_0
	colorama                  0.3.7                    py36_0
	conda                     4.3.16                   py36_0
	conda-env                 2.6.0                         0
	configobj                 5.0.6                    py36_0
	contextlib2               0.5.4                    py36_0
	cryptography              1.7.1                    py36_0
	curl                      7.52.1                        0
	cycler                    0.10.0                   py36_0
	cython                    0.25.2                   py36_0
	cytoolz                   0.8.2                    py36_0
	dask                      0.13.0                   py36_0
	datashape                 0.5.4                    py36_0
	dbus                      1.10.10                       0
	decorator                 4.0.11                   py36_0
	dill                      0.2.5                    py36_0
	docutils                  0.13.1                   py36_0
	entrypoints               0.2.2                    py36_0
	et_xmlfile                1.0.1                    py36_0
	expat                     2.1.0                         0
	fastcache                 1.0.2                    py36_1
	flask                     0.12                     py36_0
	flask-cors                3.0.2                    py36_0
	fontconfig                2.12.1                        2
	freetype                  2.5.5                         2
	get_terminal_size         1.0.0                    py36_0
	gevent                    1.2.1                    py36_0
	glib                      2.50.2                        1
	greenlet                  0.4.11                   py36_0
	gst-plugins-base          1.8.0                         0
	gstreamer                 1.8.0                         0
	h5py                      2.6.0               np111py36_2
	harfbuzz                  0.9.39                        2
	hdf5                      1.8.17                        1
	heapdict                  1.0.0                    py36_1
	icu                       54.1                          0
	idna                      2.2                      py36_0
	imagesize                 0.7.1                    py36_0
	ipykernel                 4.5.2                    py36_0
	ipython                   5.1.0                    py36_0
	ipython-genutils          0.2.0                     <pip>
	ipython_genutils          0.1.0                    py36_0
	ipywidgets                5.2.2                    py36_1
	isort                     4.2.5                    py36_0
	itsdangerous              0.24                     py36_0
	jbig                      2.1                           0
	jdcal                     1.3                      py36_0
	jedi                      0.9.0                    py36_1
	jinja2                    2.9.4                    py36_0
	Jinja2                    2.9.6                     <pip>
	jpeg                      9b                            0
	jsonschema                2.5.1                    py36_0
	jupyter                   1.0.0                    py36_3
	jupyter_client            4.4.0                    py36_0
	jupyter_console           5.0.0                    py36_0
	jupyter_core              4.2.1                    py36_0
	jupyterhub                0.7.2                     <pip>
	lazy-object-proxy         1.2.2                    py36_0
	libffi                    3.2.1                         1
	libgcc                    4.8.5                         2
	libgfortran               3.0.0                         1
	libiconv                  1.14                          0
	libpng                    1.6.27                        0
	libsodium                 1.0.10                        0
	libtiff                   4.0.6                         3
	libxcb                    1.12                          1
	libxml2                   2.9.4                         0
	libxslt                   1.1.29                        0
	llvmlite                  0.15.0                   py36_0
	locket                    0.2.0                    py36_1
	lxml                      3.7.2                    py36_0
	Mako                      1.0.6                     <pip>
	MarkupSafe                1.0                       <pip>
	markupsafe                0.23                     py36_2
	matplotlib                2.0.0               np111py36_0
	mistune                   0.7.3                    py36_0
	mkl                       2017.0.1                      0
	mkl-service               1.1.2                    py36_3
	mpmath                    0.19                     py36_1
	multipledispatch          0.4.9                    py36_0
	nbconvert                 4.2.0                    py36_0
	nbformat                  4.2.0                    py36_0
	networkx                  1.11                     py36_0
	nltk                      3.2.2                    py36_0
	nose                      1.3.7                    py36_1
	notebook                  5.0.0                    py36_0
	numba                     0.30.1              np111py36_0
	numexpr                   2.6.1               np111py36_2
	numpy                     1.11.3                   py36_0
	numpydoc                  0.6.0                    py36_0
	odo                       0.5.0                    py36_1
	openpyxl                  2.4.1                    py36_0
	openssl                   1.0.2k                        1
	pamela                    0.3.0                     <pip>
	pandas                    0.19.2              np111py36_1
	partd                     0.3.7                    py36_0
	path.py                   10.0                     py36_0
	pathlib2                  2.2.0                    py36_0
	patsy                     0.4.1                    py36_0
	pcre                      8.39                          1
	pep8                      1.7.0                    py36_0
	pexpect                   4.2.1                    py36_0
	pickleshare               0.7.4                    py36_0
	pillow                    4.0.0                    py36_0
	pip                       9.0.1                    py36_1
	pixman                    0.34.0                        0
	ply                       3.9                      py36_0
	prompt_toolkit            1.0.9                    py36_0
	psutil                    5.0.1                    py36_0
	ptyprocess                0.5.1                    py36_0
	py                        1.4.32                   py36_0
	pyasn1                    0.1.9                    py36_0
	pycosat                   0.6.1                    py36_1
	pycparser                 2.17                     py36_0
	pycrypto                  2.6.1                    py36_4
	pycurl                    7.43.0                   py36_2
	pyflakes                  1.5.0                    py36_0
	pygments                  2.1.3                    py36_0
	pylint                    1.6.4                    py36_1
	pyopenssl                 16.2.0                   py36_0
	pyparsing                 2.1.4                    py36_0
	pyqt                      5.6.0                    py36_2
	pytables                  3.3.0               np111py36_0
	pytest                    3.0.5                    py36_0
	python                    3.6.1                         0
	python-dateutil           2.6.0                    py36_0
	python-editor             1.0.3                     <pip>
	pytz                      2016.10                  py36_0
	pyyaml                    3.12                     py36_0
	pyzmq                     16.0.2                   py36_0
	qt                        5.6.2                         3
	qtawesome                 0.4.3                    py36_0
	qtconsole                 4.2.1                    py36_1
	qtpy                      1.2.1                    py36_0
	readline                  6.2                           2
	redis                     3.2.0                         0
	redis-py                  2.10.5                   py36_0
	requests                  2.12.4                   py36_0
	requests                  2.13.0                    <pip>
	rope                      0.9.4                    py36_1
	ruamel_yaml               0.11.14                  py36_1
	scikit-image              0.12.3              np111py36_1
	scikit-learn              0.18.1              np111py36_1
	scipy                     0.18.1              np111py36_1
	seaborn                   0.7.1                    py36_0
	setuptools                27.2.0                   py36_0
	simplegeneric             0.8.1                    py36_1
	singledispatch            3.4.0.3                  py36_0
	sip                       4.18                     py36_0
	six                       1.10.0                   py36_0
	snowballstemmer           1.2.1                    py36_0
	sockjs-tornado            1.0.3                    py36_0
	sphinx                    1.5.1                    py36_0
	spyder                    3.1.2                    py36_0
	sqlalchemy                1.1.5                    py36_0
	SQLAlchemy                1.1.9                     <pip>
	sqlite                    3.13.0                        0
	statsmodels               0.6.1               np111py36_1
	sympy                     1.0                      py36_0
	terminado                 0.6                      py36_0
	tk                        8.5.18                        0
	toolz                     0.8.2                    py36_0
	tornado                   4.4.2                    py36_0
	tornado                   4.5.1                     <pip>
	traitlets                 4.3.2                     <pip>
	traitlets                 4.3.1                    py36_0
	unicodecsv                0.14.1                   py36_0
	wcwidth                   0.1.7                    py36_0
	werkzeug                  0.11.15                  py36_0
	wheel                     0.29.0                   py36_0
	widgetsnbextension        1.2.6                    py36_0
	wrapt                     1.10.8                   py36_0
	xlrd                      1.0.0                    py36_0
	xlsxwriter                0.9.6                    py36_0
	xlwt                      1.2.0                    py36_0
	xz                        5.2.2                         1
	yaml                      0.1.6                         0
	zeromq                    4.1.5                         0
	zlib                      1.2.8                         3
@jpastuszek
Copy link
Author

Looks like it does not like 0<&- in init.d script which closes stdin as part of daemonizing. After I changed it it to 0</dev/null and all is OK. I never had this problem with other software though. Also for some reason I needed to remove jupyterhub.sqlite for this to take effect.

@minrk
Copy link
Member

minrk commented Apr 28, 2017

This is a bug in each of ptyprocess and the notebook application, not handing the rare case when sys.stdin is None. Patches have been submitted to each repo (links above).

Since all of these issues are in the single-user notebook servers, removing jupyterhub.sqlite and the issue being fixed could have been a coincidence. What would have been needed is relaunching the Hub and starting a new single-user server. Depending on your Spawner and configuration, it's possible that single-user servers stay running across Hub restarts, in which case the single-user server would itself need a manual restart after relaunching the Hub. Removing jupyterhub.sqlite in this case would cause the Hub to lose its information about running servers, prompting the next login to spawn a new server. If removing jupyterhub.sqlite did indeed fix the issue, that probably means that prior single-user instances are still running, but the Hub doesn't know about them.

@minrk minrk added this to the NA milestone Apr 28, 2017
@jpastuszek
Copy link
Author

Thank you very much for the info and explanation. I will use 0</dev/null as a workaround for the time being.

@willingc
Copy link
Contributor

willingc commented Aug 7, 2017

Both upstream PRs have been merged.

Closing this issue since it appears to be resolved. Please feel free to leave an issue at jupyter/help or leave a comment requesting this issue be reopened. Thanks to all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants