You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
create a new file in: $HOME/.config/ipython/profile_default/startup/00-disable-deprecation-warning.py
then put following content:
# hide deprecation warning# IPython/terminal/interactiveshell.py:432:# DeprecationWarning: With-statements now directly ...importwarningsimportexceptionswarnings.filterwarnings("ignore",
category=exceptions.DeprecationWarning,
module='IPython.terminal.interactiveshell',
lineno=432) # change lineno to your line number warning
change lineno to your line number warning and module to module that give that warning. Since it's a DeprecationWarning, use that appropriate category.
The Issue
Version of affected program:
Django 1.6
IPython 1.1.0
This issue happen in a fresh Django project.
When you start python manage.py shell in a IPython shell, you'll encounter this
Deprecation warning
/home/adit/.virtualenv/local/lib/python2.7/site-packages/
IPython/terminal/interactiveshell.py:432: DeprecationWarning: With-statements now
directly support multiple context managers
with nested(self.builtin_trap, self.display_trap):
Reading the discussion, you'll notice that it was fixed in the 2.x version of IPython
(the master branch). So, you won't get it fixed in the current version unless someone (?) give a pull request to fix it.
Based on the documentation link above, IPython configuration file location was searched in the following directory:
direcotry that given to --ipython-dir=<directory> command line flag
$HOME/.config/ipython (in Unix, Linux, etc.)
$HOME/.ipython
In that order above. The first found will be used. Refer to the documentation for more explanation.
Anyway, you could execute following command to find your configuration directory.
$ ipython locate/home/adit/.config/ipython
In the directory that given by the output of the command above, you'll find profile_default directory. (to generate the file if it doesn't exist execute ipython profile create).
On the subfolder startup of the above directory, you could put any python script (.py) or IPython script (.ipy) that will be executed in lexicographic order when you start IPython.
Create following file in that folder
# hide deprecation warning# IPython/terminal/interactiveshell.py:432:# DeprecationWarning: With-statements now directly ...importwarningsimportexceptionswarnings.filterwarnings("ignore",
category=exceptions.DeprecationWarning,
module='IPython.terminal.interactiveshell',
lineno=432) # change lineno to your line number warning
Take a note of your warning, change the module and lineno parameter according
your case.
TLDR
create a new file in:
$HOME/.config/ipython/profile_default/startup/00-disable-deprecation-warning.py
then put following content:
change
lineno
to your line number warning andmodule
to module that give that warning. Since it's aDeprecationWarning
, use that appropriatecategory
.The Issue
Version of affected program:
This issue happen in a fresh Django project.
When you start
python manage.py shell
in a IPython shell, you'll encounter thisDeprecation warning
This issue was reported in https://code.djangoproject.com/ticket/19789
But, that was invalid since the actual issue is on the IPython side. The link to the IPython github issue was this: ipython/ipython#4455
Reading the discussion, you'll notice that it was fixed in the 2.x version of IPython
(the master branch). So, you won't get it fixed in the current version unless someone (?) give a pull request to fix it.
Workaround
A work around to fix this warning is by using IPython configuration.
http://ipython.org/ipython-doc/stable/config/overview.html
Based on the documentation link above, IPython configuration file location was searched in the following directory:
--ipython-dir=<directory>
command line flag$HOME/.config/ipython
(in Unix, Linux, etc.)$HOME/.ipython
In that order above. The first found will be used. Refer to the documentation for more explanation.
Anyway, you could execute following command to find your configuration directory.
In the directory that given by the output of the command above, you'll find
profile_default
directory. (to generate the file if it doesn't exist executeipython profile create
).On the subfolder
startup
of the above directory, you could put any python script (.py) or IPython script (.ipy) that will be executed in lexicographic order when you start IPython.Create following file in that folder
Take a note of your warning, change the
module
andlineno
parameter accordingyour case.
For my case, I get this line in the warning:
That means I must cange
category
toexecption.DeprecationWarning
,module to
IPython.terminal.interactiveshell, andlineno
to432
.Give that file any name you want, for example:
00-disable-deprecation-warning.py
and save it.Now, when you start IPython the deprecation warning will disappear.
The text was updated successfully, but these errors were encountered: