takluyver / nbopen

Open a Jupyter notebook in the best available server
BSD 3-Clause "New" or "Revised" License
301 stars 58 forks source link

nbopen does not work, it simply flashes Python interpreter command prompt #69

Open richlysakowski opened 4 years ago

richlysakowski commented 4 years ago

I ran the nbopen installation and activation commands on Windows 10 . I am using a new installation of Anaconda Python distribution (new as of last week 1/10/2020).

python -m pip install nbopen python -m nbopen.install_win

Then I double-click on a Jupyter notebook file, the interpreter Command Prompt flashes, but the Jupyter NB file never opens up. I saw this behavior about 11 months ago the first time I tried it. What is the fix for this?

Guillaume-Garrigos commented 4 years ago

Same problem here, with the latest Anaconda distribution on W10.

takluyver commented 4 years ago

Does using nbopen in a command prompt work? If so, it's really hard to debug this: there's an error message that vanishes before you can read it. Maybe try taking screenshots at just the right moment? Or a screen recording you can pause? I know that's a terrible way to debug, but it's all I can suggest.

On Fri, 31 Jan 2020, 11:46 Guillaume Garrigos, notifications@github.com wrote:

Same problem here, with the latest Anaconda distribution on W10.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/takluyver/nbopen/issues/69?email_source=notifications&email_token=AACQB5J4MB6YGKKTHOWE6UDRAP6RZA5CNFSM4KG55HD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKOIRNY#issuecomment-580683959, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACQB5IOEBHVJMN6IDXWH4DRAP6RZANCNFSM4KG55HDQ .

Guillaume-Garrigos commented 4 years ago

In a command prompt i do nbopen file_name.ipynb

On my first try the command prompt says "Using existing server at D:\" and Firefox opens an error tab with "Firefox can’t establish a connection to the server at localhost:8888." From this I guess there is an issue with different hard drives C:\ D:\ , for instance my Anaconda/python/environments are in C:\ but my data (and notebooks) are in D:\

So, I move the notebook on C:\ and there nbopen works from the command prompt. But if I double click on the file, it keeps opening with my default text editor, even though I did python -m nbopen.install_win . Do I have to do something else to "force" the file association? Also, note that I used python and not python3 because the command is not recognized for me.

takluyver commented 4 years ago

Notebooks on D: shouldn't be a problem, but it sounds like there might be a leftover server file for a server that no longer exists. Try running 'jupyter notebook list' in the command prompt. There's a file that should be deleted when the notebook server shuts down, but maybe wasn't. I'm typing on a phone now, though, so I can't give much detail.

Does windows still have an "open with" option if you right click a file? I haven't used it much for years.

On Fri, 31 Jan 2020, 15:10 Guillaume Garrigos, notifications@github.com wrote:

In a command prompt i do nbopen file_name.ipynb

On my first try the command prompt says "Using existing server at D:" and Firefox opens an error tab with "Firefox can’t establish a connection to the server at localhost:8888." From this I guess there is an issue with different hard drives C:\ D:\ , for instance my Anaconda/python/environments are in C:\ but my data (and notebooks) are in D:\

So, I move the notebook on C:\ and there nbopen works from the command prompt. But if I double click on the file, it keeps opening with my default text editor, even though I did python -m nbopen.install_win . Do I have to do something else to "force" the file association? Also, note that I used python and not python3 because the command is not recognized for me.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/takluyver/nbopen/issues/69?email_source=notifications&email_token=AACQB5LITNAFTVDIPXVTO5DRAQWMTA5CNFSM4KG55HD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKOYGIY#issuecomment-580748067, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACQB5LA5SJBDIZ5FQX6QHDRAQWMTANCNFSM4KG55HDQ .

matt-sharp commented 4 years ago

Has anyone found a solution to this issue? I can launch Jupyter Notebook from the Anaconda prompt using nbopen but not when double clicking from file explorer.

Guillaume-Garrigos commented 4 years ago

Sorry, I completely missed @takluyver answer months ago. For the record, my issue with D: was indeed because I had a server 8888 not shut down properly, so I had to delete a file somewhere (following this https://github.com/jupyter/notebook/issues/2844#issuecomment-369570970)

So, back on our problem, I can use nbopen from the command prompt, it works well. Double-clicking doesn't. I tried to go through "Right-Click>Open with>nbopen.exe" , in which case it doesn't work. But a prompt opens and close in a blink, and I have been able to catch it, see the attached screenshot. I hope it can help.

17-06-2020 17-46-12

matt-sharp commented 4 years ago

I just managed to fix mine by following some steps when you get the DLL load failed error, many thanks for the screenshot! Make sure you have the following in your PATH variable:

c:\users\USERNAME\anaconda3 c:\users\USERNAME\anaconda3\scripts c:\users\USERNAME\anaconda3\library\bin c:\users\USERNAME\anaconda3\library\usr\bin where c:\users\USERNAME\anaconda3 is the anaconda install location.

I was missing the 2 bin directory paths above.

KamarajuKusumanchi commented 4 years ago

@nekro9t2 Thanks. Adding the paths solved the issue for me.

takluyver commented 4 years ago

Sorry all, I don't know much about Windows. The error @Guillaume-Garrigos managed to capture looks like the French translation of the common DLL load failed: The specified module could not be found error, which unhelpfully omits to tell you which DLL couldn't be found. It makes sense that modifying the PATH environment variable helps, as @nekro9t2 found, because Windows uses that to look for DLLs (as well as commands, which is the primary purpose of it).

@nick-025 :

I always get a red error message.

Please do include the actual error message! Even if it's the same generic error as in @Guillaume-Garrigos's post, it's a useful hint whether you're facing a similar problem or a different one.

Greedquest commented 3 years ago

A slightly neater alternative to what @matt-sharp suggests is to get conda to run* nbopen for you, so that you don't need to modify the PATH at all

The easiest way is to go to the registry with Regedit and change the key at Computer\HKEY_CURRENT_USER\SOFTWARE\Classes\Jupyter.nbopen\shell\open\command to

C:\Users\{USERNAME}\anaconda3\python.exe -m conda run -n base pythonw -m nbopen "%1"

... ofc swap C:\Users\{USERNAME}\anaconda3\python.exe ... for whichever python executable is currently referenced (i.e. change USERNAME)


Note:

  1. run -n base will run nbopen in the environment named base, but you may have installed it in a different environment so you can change that here.
  2. If, like me, your anaconda base installation is your default python version then you can replace the C:\Users\{USERNAME}\anaconda3\python.exe with py which should do the same thing using the windows python launcher (installed by default).
  3. A terminal window may flash but it's fine to close it if it stays open, I asked about a fix over on SO here.

*NB: conda run is a beta feature at time of writing so this approach may break if the api changes, but it seems to work fine for now

nick-025 commented 3 years ago

So, after a very long time, I was trying to use nbopen with double click, and unfortunately, nothing has changed. I can use it perfectly though with command line. I had already checked a lot of comments and threads, but this error was still happening (as it happened to @Guillaume-Garrigos):

nbopen error 1

I then added the bin paths and the Anaconda installation folder to the System Path, as described by @matt-sharp. But that did not work at all. I get an empty command line window, and even after using python -m nbopen.install_win it says I am running that with nbopen.exe. I don't know how to proceed right now. I am not giving up on it, if anyone has an idea of what is going on, their help would be greatly appreciated!

image

Greedquest commented 3 years ago

@nick-025 If it works through the anaconda prompt, then what I suggested should work too, as it basically runs the nbopen command in the anaconda environment behind the scenes. The method I suggest just overwrites one of the steps in nbopen.install_win

nick-025 commented 3 years ago

I confess I was afraid of changing these deep configurations, since I am not an expert in this subject. But it works now. I just saw a python window and a node.js one, but that's not relevant for me at all. It is working now. Thank you so much for the instructions @Greedquest, you helped me a lot!!!

Greedquest commented 3 years ago

@nick-025 I understand. The registry can be used to configure some quite important things in the Operating System (and break them). However in this case it's being used more like a text file/dictionary just to store the command string on the computer somewhere so it can be accessed later.

PS. If the method worked then maybe thumbs up the original post so other people can see it works and use it themselves?

nick-025 commented 3 years ago

Of course! Your contribution will help lots of people, it is important to recognize others effort!

ejad9 commented 2 years ago

Hi all, I had the same issue and I've fixed it by :

  1. Uninstalling Anaconda
  2. Reinstalling Anaconda clicking "Add Anaconda to the PATH" when proposed
  3. Reinstalling nbopen : in the Anaconda Powershell Prompt :
    • pip install nbopen
    • python -m nbopen.install_win

I can now open .ipynb files by doucle-clicking on it That feel so great ! :)

JeranYang commented 2 years ago

Hi all, I had the same issue and I've fixed it by :

  1. Uninstalling Anaconda
  2. Reinstalling Anaconda clicking "Add Anaconda to the PATH" when proposed
  3. Reinstalling nbopen : in the Anaconda Powershell Prompt :
  • pip install nbopen
  • python -m nbopen.install_win

I can now open .ipynb files by doucle-clicking on it That feel so great ! :)

Same issue. Thank you, ejad9! It never comes to me that this issue dates all the way back to the installation of Anaconda. I remember Anaconda didn't recommend "Add Anaconda to the PATH"...

But I still have a problem that the notebook on my desktop cannot be opened. It returns the error "404 : Not Found". I think this issue is caused by a space key in my Windows user folder name. But changing the user folder name is another complex issue and may cause severe problems to the computer. So I decided to stop here.