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

Random switch from py2.7 to 3 #2721

Open
StephaneKazmierczak opened this issue Aug 2, 2017 · 4 comments
Open

Random switch from py2.7 to 3 #2721

StephaneKazmierczak opened this issue Aug 2, 2017 · 4 comments
Milestone

Comments

@StephaneKazmierczak
Copy link

Hi,

While working on a notebook using python 2.7, from time to time the cell will switch to python 3 syntaxe.
for example trying to execute a cell, I will get error messages asking me to add () to my prints, I just have to close the notebook and reopen to fix the issues.

It is really strange as I didn't install python 3 kernel on the server that i am using and only have python 2 available from jupyter drop-down menu.

@takluyver
Copy link
Member

Is it possible that you're running code containing from __future__ import print_function?

Can you check sys.version and sys.executable before and after it happens?

@takluyver takluyver added this to the Reference milestone Aug 7, 2017
@StephaneKazmierczak
Copy link
Author

StephaneKazmierczak commented Sep 20, 2017

Hi sorry for delay, I moved on to something else and forget to check here, but sys.version return

3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609]

Also I am using the Linux layer on windows 10. The problem may come from that.

when starting python from command line:

$pyhton
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.

@StephaneKazmierczak
Copy link
Author

StephaneKazmierczak commented Sep 20, 2017

I just fix it, the config for kernel/python2/kernel.json what using argv : [ "python"
I just replace by python by /usr/bin/python2.7 and now it is working, it is really strange as /usr/bin/python link to python2.7 but for some reason now it is working

@takluyver
Copy link
Member

There's a special case in the code to interpret "python" as the same Python executable which is running the notebook server. So if your notebook server is running on Python 3, any kernel with "python" as the first argument will run with that too.

This has been causing some confusion. I have a plan to change how kernels are found more generally, which I hope will make it easier to understand as well: jupyter/jupyter_client#261

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

No branches or pull requests

2 participants