Comments (5)
There is no hidden import in notebook, nor in terminal. Do you have a custom config ?
What import do you have in mind ?
(the ipython/nbconvert is indeed legacy code with have for historical reasons)
from nbconvert.
Hi Matthias!
Thanks for your response.
I had to add the following, after giving up on trying to use IPython
magics from inside my python script (in particular, my notebook had
"%pylab inline"):
import cProfile
import datetime
from functools import reduce
import itertools
import math
import pstats, io
from subprocess import check_output, call
import sys
import time
import warnings
import cairocffi
from IPython.utils.encoding import DEFAULT_ENCODING
from scipy.optimize import curve_fit
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import numpy as np
The first 10 or so are definitely core python packages (I admit that
some of these I loaded by hand, e.g. cProfile). The bottom 5 are
probably loaded by the %pylab magic.
Are none of the imports above loaded implicitly??
Thanks,
Inon Sharony
ינון שרוני
+972(3)6407634
http://www.TAU.ac.IL/~inonshar
Please consider your environmental responsibility before printing this e-mail.
Quoting Matthias Bussonnier [email protected]:
There is no hidden import in notebook, nor in terminal. Do you have
a custom config ?
What import do you have in mind ?(the ipython/nbconvert is indeed legacy code with have for
historical reasons)
Reply to this email directly or view it on GitHub:
#54 (comment)
from nbconvert.
Well, no, none of the above packages are imported implicitely by default.
you import them by doing %pylab inline
, and this is one of the reason %pylab
is undocumented and deprecated. %pylab
is not ment to do inline graph. %matplotlib inline
is ment to do that. If you do not know what %pylab
does, then you probably should not use it, or it will bite you in other places.
Magics are non python syntax, so no magic will ever be valid in Python script.
Though, most magics are "just" syntactic sugar for Python expression, that hist -t
can show you:
In [1]: %matplotlib inline
UsageError: Invalid GUI request 'inline', valid ones are: wx, osx, qt, qt5, glut, gtk, tk, pyglet, gtk3
In [2]: hist -t
get_ipython().magic('matplotlib inline')
get_ipython().magic('hist -t')
It does not really help you though as most of the magic need access to a ipython shell to work, but can at least make the syntax valid.
Feel free to continue asking if you have more questions,
closing the bug for now.
from nbconvert.
Wow, Matthias, thanks for a wonderful explanation!
I really appreciate that you took the time. I'm sure someone will
probably benefit from it in the future (all user errors reproduce
after a while... :-)
I was just a bit thrown off by [the
documentation explaining how to embed](https://ipython.org/ipython-doc/dev/interactive/reference.html) an instance of IPython
in a regular python script, so I thought I might do that. Since
invoking get_ipython() did not work for me after a reasonable
effort, I decided to give up on IPython for non-interactive
computations.
As for *pylab*, I'll heed your advice and switch to *%matplotlib inline*
for my notebook plotting. Again, I just took existing tutorials and
such which almost always begin with *%pylab inline*. I'll have to
figure out which of the other imports I'll have to do explicitly in
the notebook.
IMHO all of the points you discussed are worth mentioning in some
highly visible place on the project website and/or documentation, to
save people the trouble of figuring these things out the hard way.
Thank you, again,
and have a wonderful weekend!
from nbconvert.
Here is (roughly) what %pylab
does
import numpy
import matplotlib
from matplotlib import pylab, mlab, pyplot
np = numpy
plt = pyplot
from IPython.core.pylabtools import figsize, getfigs
from pylab import *
from numpy import *
The problem with writing loud and clear what not to do, is that people will not remember why it's wrong and what the issues are, they will just remember they can do it.
from nbconvert.
Related Issues (20)
- Convert to MyST HOT 1
- Word wrapping for print view in HTML output
- Can someone help me out with why my images wont display on my pdf print
- Error in docs example: Using nbconvert as a library: KeyError: 'template_paths' HOT 1
- Section numbering in HTML
- Nbconvert >= 7.14 produces error in Sphinx build HOT 9
- Allow pre-fetching of css files? HOT 2
- matplotlib widgets not interactive when exported to html
- Rendering to HTML generates an error in bleach.clean HOT 5
- No way to disable traceback colors when executing notebook HOT 1
- Jupyter Magic stops `CellExecutionError` handling from working
- jupyter/nbconvert/templates only has latex HOT 5
- Unable to convert .ipynb to .pdf on Mac
- Erreur with date metadata
- Export to PDF with bengali language failed
- Error with ucs package when exporting .ipynb to pdf file HOT 2
- nbconvert not recognizing filepaths when appending .ipynb to the end of the filename
- Attached images not exported when converting to reStructuredText
- mermaid only renders after pressing "F5" on reveal slides (including semi fix...) HOT 2
- Unable to convert notebook to Markdown ("ModuleNotFoundError"; macOS)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nbconvert.