-
Notifications
You must be signed in to change notification settings - Fork 181
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
Feature request: jupyter command searches in Python's "scripts" directory for subcommands #160
Comments
I am using Python 3.8 installed from Microsoft Store. I noticed that the directory returned by |
Hmm, it sounds like the store build has a rather strange setup. Does patching diff --git a/jupyter_core/command.py b/jupyter_core/command.py
index b9c60d2..8f8a63d 100644
--- a/jupyter_core/command.py
+++ b/jupyter_core/command.py
@@ -164,7 +164,8 @@ def _path_with_self():
# The Python environment does not specify a "scripts" location
pass
else:
- path_list.append(bindir)
+ if bindir is not None:
+ path_list.append(bindir)
scripts = [sys.argv[0]]
if os.path.islink(scripts[0]): |
Sorry I didn’t make myself clear. I mean on my PC, running
And this directory does not exist. Running
This directory exists, and contains “jupyter-notebook.exe” in it. To my understanding, those two directories are like system scripts path and user scripts path. The Python from Microsoft Store version doesn’t have system scripts path. Instead, using |
In that case, surely everything will still work fine, as the code will still search alongside
As the directory doesn't exist, it should just get ignored (if I understand the code that uses the path list). Can you explain exactly how launching the notebook fails? What error (and traceback) do you get? |
Traceback:
The code tries to find an executable named “jupyter-notebook.exe”, but it is in the user scripts path. The current implementation only searches system scripts path, and it can’t find the executable, so the exception is raised. |
Is the jupyter command itself not in the user scripts path?
It doesn't (as far as I know) only search the system scripts path, rather it searches the system path in addition to the previously searched directories (the contents of Note: If you are saying that you'd like an additional change to search the user scripts path as well as the system scripts path, then I see no problem with that, although it should probably be a separate request and someone would need tow rite a PR. My concern here is that you seem to be saying that this change has broken a previously working scenario, which the PR I submitted should not have done. |
No, your PR didn’t break anything. I installed Jupyter Notebook, and couldn’t start it, so I did a little digging. I guess the problem is because the correct scripts path not being searched, and this issue is about adding scripts path to search paths, so I commented my findings here, hoping my findings could help fixing the problem. |
OK cool. I'm still not clear why the existing code doesn't find @zooba is the expert on the store build - maybe he can comment? |
|
From https://jupyter.org/install:
I think this is also because of user scripts directory not being searched. Maybe if this is fixed, user-level This problem can also be reproduced using Docker:
|
My use case here is fairly unusual, so it may be that this is something you don't want to support. But what I am trying to do is as follows. I want to keep my Jupyter environment isolated from my system Python, so I install it into a virtual environment. If I do that, and run
jupyter notebook
, either with the venv activated, or using the full path to thejupyter.exe
command, everything works as expected.However, I would rather not need to activate the environment, or use the full path (I don't want to accidentally run the venv python, and typing the full path on the command line is a pain). I could use an alias for that, but what I usually do is copy the script wrapper (
jupyter.exe
) to my~/.local/bin
directory. This works for other applications, but jupyter fails to find its subcommands if I do this.The problem seems to be in
jupyter_core.command
in function_path_with_self
, which adds the directory containing the executable toPATH
, for looking up subcommands. That fails if thejupyter.exe
program gets moved.A fix which seems to work for me is to add
sysconfig.get_path('scripts')
to the list of paths added toPATH
. A proof of concept fix to_path_with_self
is as follows:Is this something that could be considered for inclusion? I don't think it will cause problems anywhere else, and even though my use case is unusual, looking in the
scripts
location is a fairly natural and reasonable thing to do anyway.I can create a PR for this if there is interest.
The text was updated successfully, but these errors were encountered: