Skip to content

PYTHONPATH first element not used in jupyter preview #6962

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

Closed
1 task done
jordansamuels opened this issue Jul 9, 2024 · 2 comments · Fixed by #7059
Closed
1 task done

PYTHONPATH first element not used in jupyter preview #6962

jordansamuels opened this issue Jul 9, 2024 · 2 comments · Fixed by #7059
Milestone

Comments

@jordansamuels
Copy link
Contributor

This bug appears related to the change in #4489 . That change uses sys.path[1:] , but this means that the first element of the path is omitted. This causes import issues in panel preview when importing a file from the first element of the PYTHONPATH. Moreover, if I locally change to sys.path instead of sys.path[1:] in panel/io/jupyter_server_extension.py then it fixes the issue.

ALL software version info

  • panel=1.4.4=pyhd8ed1ab_0
  • python=3.11.9=h932a869_0_cpython
  • jupyterlab=4.2.3=pyhd8ed1ab_0

Tested on OSX and Linux.
Full software versions in repro here.

Description of expected behavior and the observed behavior

Full repro instructions at https://github.com/jordansamuels/panel-jupyter-path-bug-repro.
Expected: panel preview works in jupyter lab.
Observed: import exception.

Complete, minimal, self-contained example code that reproduces the issue

Full repro at https://github.com/jordansamuels/panel-jupyter-path-bug-repro.

Stack traceback and/or browser JavaScript console output

(none relevant that I could find)

Screenshots or screencasts of the bug in action

image
  • I may be interested in making a pull request to address this
@philippjfr philippjfr added this to the v1.5.0 milestone Jul 9, 2024
@MarcSkovMadsen
Copy link
Collaborator

Hi @jordansamuels

Thanks for the well described bug report. You could try to make the PR by just changing sys.path = [os.getcwd()] + sys.path[1:] to sys.path = [os.getcwd()] + sys.path.

As there is no test or documentation of the change in 4489, then Philipp would be the only one knowing why it was [1:] anyways and he would be able to quickly pick up and adjust your PR if needed.

jordansamuels added a commit to jordansamuels/panel that referenced this issue Aug 2, 2024
@jordansamuels
Copy link
Contributor Author

[...] You could try to make the PR by just changing sys.path = [os.getcwd()] + sys.path[1:] to sys.path = [os.getcwd()] + sys.path.

Thanks! I made PR #7059 for this. This is my first PR for this repo, so please let me know if I can adjust anything.

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

Successfully merging a pull request may close this issue.

3 participants