-
Notifications
You must be signed in to change notification settings - Fork 557
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
Nbconvert's shebang ignores the version of the kernel in every notebook that is converted to Python #1390
Comments
Hmm while that is correct that it doesn't use kernel information to populate the shebang, not all machines have a python3 or python3.8 installed, so you might end up with a shebang that couldn't be respected. Also not all kernels specify their python version so it's sometimes impossible to respect this: {
"argv": [
"/home/mseal/.py3local/bin/python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
} as an example kernel spec file on my machine. One could launch the kernel, read the sys.version, and use that to fix the latter issue. Though I'd be hesitant to add that to the preprocessor as it's a LOT slower and process heavy to do that than the current preprocessor. Would adding an argument option to the preprocessor to allow you to set the shebang python version meet needs? |
These are valid points, I absolutely agree with them.
Well, it doesn't really seem to address my main issue with the shebang: the fact that in its current form it might produce unexpected results, which falls into the "bug" category for me. If I use a Python3.8 kernel in a notebook, I think it's reasonable for me to expect the converted script either
To be honest I'd prefer the second option, simply because I don't think that it's I personally would be satisfied (to different extents though) with the following solutions for this issue:
Another argument for revoking the feature would be that that even though the shebang-idea was was a proposal from the community (and eventually a PR): #690, I don't really see many people asking for it (in that specific issue, or in any other one). An argument for leaving this situation as it is would be that my concerns had been (in a way) already addressed in the discussion of the PR, but they got brushed off with the following argument:
While I do not agree with this argument, I can accept the reasoning, that the options were already considered, and a decision was already made by the project. (By the way, thank you for the quick and helpful response! |
Thanks for clearly documenting the decisions made in the past. I have a similar PoV as you do on your response for how I would approach it given a fresh project without a prior opinion. However I have found changing anything in this project breaks someone's workflow as there's a lot of subtle implicit edges exposed, and plus prior authors seemed to have a strong opinion on the setup. So I am inclined towards option 2 to avoid more pain unless other maintainers think we should go with something else and pipe up. For now I'll add documentation about the current state of things. |
👍 Option 2 with documentation seems to be a good solution considering all the points you mentioned. |
This is the shebang that
nbconvert
prepends to the beginning of every notebook that it converts to python:#!/usr/bin/env python
Since the shebang is always the same, the specific version of the Python kernel in the notebook is always ignored, which is unfortunate, since one could have multiple kernels installed at the same time (for example I have
Python3.6
,Python3.7
andPython3.8
notebooks).nbconvert
:#!/usr/bin/env python
).I uploaded a Python notebook, that has two cells:
"python"
is in youPATH
(on Unix systems, I don't know about Windows).If the outputs are different, the problem is obvious. If they are not, then check out the five steps I mentioned below, which provide you a much better way to reproduce the issue.
python-3.6.txt
Nbconvert version: 5.6.1
The text was updated successfully, but these errors were encountered: