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

Spyder-Notebook does not switch PythonPath when changing 'project' in spyder #302

Open
aviolov opened this issue Jul 15, 2020 · 3 comments

Comments

@aviolov
Copy link

aviolov commented Jul 15, 2020

Description of your problem

What steps will reproduce the problem?

  1. I have two projects in spyder (Q,X). One of the killer features of Spyder-notebook is that it adds the project to the pythonpath, which makes using notebooks with our code base easier
  2. However if I open a new project (say switch from X-> Q) in spyder, the pythonpath in the notebook still is bound to X

What is the expected output? What do you see instead?
I would hope that it would switch to Q

Please provide any additional information below (stack trace, screenshots, a gif, etc)

Versions and main components

$ cat environment.yml | grep 'spyder\|python\|qt\|jupyter'

  • ipython=7.16.1=py37h5ca1d4c_0
  • jupyter=1.0.0=py37_7
  • jupyter_client=6.1.3=py_0
  • jupyter_console=6.1.0=py_0
  • jupyter_core=4.6.3=py37_0
  • pyqt=5.9.2=py37ha878b3d_0
  • python=3.7.7=h81c818b_4
  • qt=5.9.7=vc14h73c81de_0
  • qtawesome=0.7.2=py_0
  • qtconsole=4.7.5=py_0
  • qtpy=1.9.0=py_0
  • spyder=4.1.3=py37_0
  • spyder-kernels=1.9.1=py37_0
  • spyder-line-profiler=0.2.1=pyh9f0ad1d_0
  • spyder-notebook=0.2.3=pyh9f0ad1d_0

OS = Windows 10 SP Version 10.0.19041 Build 19041

Dependencies

Mandatory:

atomicwrites >=1.2.0 : 1.4.0 (OK)
chardet >=2.0.0 : 3.0.4 (OK)
cloudpickle >=0.5.0 : 1.4.1 (OK)
diff_match_patch >=20181111 : 20181111 (OK)
intervaltree : None (OK)
IPython >=4.0 : 7.16.1 (OK)
jedi =0.15.2 : 0.15.2 (OK)
nbconvert >=4.0 : 5.6.1 (OK)
numpydoc >=0.6.0 : 1.0.0 (OK)
paramiko >=2.4.0 : 2.7.1 (OK)
parso =0.5.2 : 0.5.2 (OK)
pexpect >=4.4.0 : 4.8.0 (OK)
pickleshare >=0.4 : 0.7.5 (OK)
psutil >=5.3 : 5.7.0 (OK)
pygments >=2.0 : 2.6.1 (OK)
pylint >=0.25 : 2.5.3 (OK)
pyls >=0.31.9;<0.32.0 : 0.31.9 (OK)
qdarkstyle >=2.8 : 2.8.1 (OK)
qtawesome >=0.5.7 : 0.7.2 (OK)
qtconsole >=4.6.0 : 4.7.5 (OK)
qtpy >=1.5.0 : 1.9.0 (OK)
rtree >=0.8.3 : 0.9.4 (OK)
sphinx >=0.6.6 : 3.1.1 (OK)
spyder_kernels >=1.9.1;<1.10.0 : 1.9.1 (OK)
watchdog : None (OK)
zmq >=17 : 19.0.1 (OK)

Optional:

cython >=0.21 : 0.29.20 (OK)
matplotlib >=2.0.0 : 3.2.2 (OK)
numpy >=1.7 : 1.18.5 (OK)
pandas >=0.13.1 : 1.0.5 (OK)
scipy >=0.17.0 : 1.5.0 (OK)
sympy >=0.7.3 : None (OK)

Spyder plugins:

spyder_line_profiler : 0.2.1 (OK)
spyder_notebook : 0.2.3 (OK)

@aviolov
Copy link
Author

aviolov commented Jul 15, 2020

POssibly related is #266, but there they want to change the environment, i only need the python-path

@jitseniesen
Copy link
Member

I agree that switching projects should switch the python path inside the notebook. This is probably best done by restarting the notebook kernel (and perhaps even the notebook server).

In fact, we are planning on associating opened notebooks with projects (see issue #291). If you change from project X to project Q, then all currently opened notebooks are closed and all notebooks that were open the last time you worked on project Q, are opened again. This is what is currently done with files in the editor. This change would not by itself solve the current issue, but it would make it a lot easier. If you have any feedback on this, please comment on issue #291.

@aviolov
Copy link
Author

aviolov commented Aug 19, 2020

Cool. Closing X-notebooks and reopening Q-notebooks sounds great. But, as I think you point out, this itself will not solve the PYTHONPATH problem, which is, I feel, the more vexing issue b/c if project Q and X refer to different git checkouts of the same project you could get in trouble by using the slightly wrong version with different code semantics that still 'runs' without error.

@jitseniesen jitseniesen removed the v0.4 label Apr 18, 2021
@jitseniesen jitseniesen added this to the v0.5 milestone Apr 18, 2021
@jitseniesen jitseniesen modified the milestones: v0.5, v0.5.1 Jun 25, 2023
@jitseniesen jitseniesen modified the milestones: v0.5.2, v0.6.1 May 28, 2024
@jitseniesen jitseniesen modified the milestones: v0.6.1, v0.6.2 Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants