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

python.exe window won't close on windows 10 #54

Open
richardwmcgovern opened this issue Apr 5, 2018 · 10 comments
Open

python.exe window won't close on windows 10 #54

richardwmcgovern opened this issue Apr 5, 2018 · 10 comments

Comments

@richardwmcgovern
Copy link

I followed the instructions to integrate with my file manager on Windows 10 by running:

python3 -m nbopen.install_win

It works and I am able to double-click open .ipynb files in a jupyter notebook. Doing so opens a python.exe blank terminal window (running it I presume). Unfortunately this window never closes, even after I close and halt the notebook, close the browser tabs, CNTRL + C in the anaconda prompt, close my browser. I have to restart my whole system to close those pesky python windows.

@takluyver
Copy link
Owner

I wonder, if your exe is called python3.exe instead of python.exe, this check might not be working:

executable = sys.executable
if executable.endswith("python.exe"):
executable = executable[:-10] + 'pythonw.exe'

Can you find the registry key it's set and check what Python exe it points to?

@richardwmcgovern
Copy link
Author

I'm not really sure how. Poking around regedit right now. Do you want to know the registry key for my nbopen? I don't see it in here:
HKEY_CURRENT_USER\Software\Python\PythonCore\3.5\InstalledFeatures

All of the python executables in Anaconda and elsewhere when I see them in File Explorer read "python.exe." Could it be because I use an environment named "python3" ?

@takluyver
Copy link
Owner

Have a look for HKEY_CURRENT_USER\Software\Classes\Jupyter.nbopen\shell\open\command

@richardwmcgovern
Copy link
Author

I have one entry there. Here is what I get for the value string:
"C:\Users<MyUserName>\Anaconda3\pythonw.exe" -m nbopen "%1"

@takluyver
Copy link
Owner

OK, so it did get pythonw correctly. Usually the w means that it shouldn't bring up the console window - I don't know why that's not working for you.

@richardwmcgovern
Copy link
Author

richardwmcgovern commented Apr 9, 2018

In case it matters, the extra python window does not pop up if I first open it normally through anaconda command prompt:

> jupyter notebook "mynotebook.ipynb"

Then close the browser tab.
Then double-click the .ipynb file to re-open (does not open a python window). The anaconda command prompt remains open this entire time. But I can close it manually with no problem. Not sure what's causing it to open and stay open otherwise.

@takluyver
Copy link
Owner

Ah, I bet that the cmd window opens for the kernel.

Nbopen does two different things, depending on whether Jupyter is already running. If Jupyter is running and can access the notebook, Nbopen just opens a new tab on your existing server. If not, it launches a new Jupyter server to show you the notebook you want.

When your server is running in a command prompt, the kernels it starts will inherit that console window automatically. But when it's running without a command prompt, because it was launched by double clicking a file, a new console is created for the kernel.

If I'm right, you can probably fix this locally by editing a kernel.json file (use jupyter kernelspec list to see where), and changing python.exe to pythonw.exe, so that the kernel doesn't need a console. I'm not sure how best to fix it generally, though.

@MuchInLearning
Copy link

Thank you @takluyver . I was able to solve the issue based on your instructions above to @richardwmcgovern

@richardwmcgovern
Copy link
Author

Thanks @takluyver. When I run jupyter kernelspec list it outputs this:

Available kernels:
python3 C:\Users\Richard\Anaconda3\lib\site-packages\ipykernel\resources
fastai2 C:\Users\Richard\AppData\Roaming\jupyter\kernels\fastai2

I normally use the "Python (default)" kernel. Which has path to executable:
C:\\Users\\Richard\\Anaconda3\\python.exe

Unfortunately I can't find a kernel.json file in either the python3 kernel directory, nor my Anaconda3 folder. I do have one in fastai2, but I never use this kernel. Creating a "python3" folder in Roaming/jupyter/kernels/... doesn't work.

Do you know where the default python kernel directory might be on Windows 10?

@ErikVini
Copy link

ErikVini commented Feb 1, 2019

I know this answer is a little late, but in my system the kernel.json file is at (Anaconda Install Dir)\share\jupyter\kernels\python3\, which is the directory that appears when I run the jupyter kernelspec list command in Anaconda Prompt.

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

4 participants