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

problem with warnings module #2239

Closed
gboeing opened this issue Mar 1, 2017 · 15 comments

Comments

Projects
None yet
10 participants
@gboeing
Copy link

commented Mar 1, 2017

The warnings module is behaving in unexpected ways, but only within a notebook. I'm using python 3.6.0.final.0 on windows 64 with notebook 4.4.1, jupyter_client 5.0.0, and jupyter_core 4.3.0, and ipython 5.3.0.

If I run ipython from the console and run the following code one line at a time:

import warnings
warnings.filterwarnings(action='ignore')
x = 1 + 1
warnings.resetwarnings()
x = 1 + 1

Everything runs as expected and there are no warnings displayed.

However, if I run the same code in a notebook with one line per cell, the following warning is displayed after cell 4 and again after cell 5:

C:\Anaconda\lib\json\encoder.py:199: DeprecationWarning: Interpreting naive datetime as local 2017-02-28 21:20:58.170463. Please add timezone info to timestamps.
  chunks = self.iterencode(o, _one_shot=True)

Essentially, any time after running warnings.resetwarnings() at any point in a notebook, every subsequent cell execution displays that warning message with the current timestamp.

@takluyver

This comment has been minimized.

Copy link
Member

commented Mar 1, 2017

That's a warning coming from some of the kernel code. It's hidden by default, but when you reset the warning filters, you'll see it. Terminal IPython doesn't use the code path that causes the warning.

@gboeing

This comment has been minimized.

Copy link
Author

commented Mar 1, 2017

Thanks @takluyver. This is new behavior -- the same code did not show the warning in the previous notebook/jupyter version... if I need to temporarily filterwarnings in the latest version notebook, how do I return to the original level when I'm done?

@takluyver

This comment has been minimized.

Copy link
Member

commented Mar 1, 2017

@gboeing

This comment has been minimized.

Copy link
Author

commented Mar 1, 2017

Yes that works. For reference, here's the code that works with Python 3.6 to temporarily suppress warnings in a notebook, without having to explicitly reset the warning filters when you're done:

import warnings
with warnings.catch_warnings():
    warnings.simplefilter('ignore')
    # do something here and its warning is suppressed
@basnijholt

This comment has been minimized.

Copy link

commented Mar 23, 2017

I am getting these warnings all in almost all cells.

Not sure why it happens.

@mimischi

This comment has been minimized.

Copy link

commented Mar 24, 2017

Same here. Just updated my python packages to their latest versions and now getting these warning in every cell.

@basnijholt

This comment has been minimized.

Copy link

commented Mar 24, 2017

It's especially bad when you connect to a few hundred ipyparallel engines and this warning is printed many many times.

@QuentinAndre

This comment has been minimized.

Copy link

commented Mar 25, 2017

Same issue here. It started when I updated the python packages as well.

@jmwenda

This comment has been minimized.

Copy link

commented Mar 30, 2017

Any pointers to this?

@bastewart

This comment has been minimized.

Copy link

commented Mar 30, 2017

I'm experiencing this as well in my notebooks. I'm not sure if this is the repository that needs to fix the issue but it seems to be most appropriate.

@gboeing Do you mind re-opening this so it becomes a bit more visible?

@gboeing gboeing reopened this Mar 30, 2017

@j-min

This comment has been minimized.

Copy link

commented Mar 31, 2017

Same issue

@jnvandermeer

This comment has been minimized.

Copy link

commented Apr 5, 2017

+1

@minrk

This comment has been minimized.

Copy link
Member

commented Apr 6, 2017

For people seeing this, what's pip list or conda list? ipython/ipykernel#239 should fix it for people in notebooks.

@basnijholt when you see this with ipyparallel, what version do you have? Do you have an ipyparallel snippet that reproduces it? 6.0 should have resolved any naïve datetimes.

@gboeing

This comment has been minimized.

Copy link
Author

commented Apr 7, 2017

@minrk python 3.6.1.final.0

ipykernel                 4.6.0                    py36_0    conda-forge
ipython                   5.3.0                    py36_0    conda-forge
ipython_genutils          0.2.0                    py36_0    conda-forge
jupyter_client            5.0.1                    py36_0    conda-forge
jupyter_core              4.3.0                    py36_0    conda-forge
nbconvert                 5.1.1                    py36_1    conda-forge
nbformat                  4.2.0                    py36_0    conda-forge
notebook                  5.0.0                    py36_0    conda-forge

@minrk minrk added this to the Not Notebook milestone Apr 11, 2017

@minrk

This comment has been minimized.

Copy link
Member

commented Apr 11, 2017

These warnings should be fixed with ipykernel 4.6.1, which is out on PyPI and should be up on conda-forge within a day or so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.