If open a python jyputer notebook in vscode, then try to execute the notebook (so a kernel starts) and realize I need to activate a different environment, there doesn't seem to be a way to switch environments without completely quitting VSCode and coming back in.
If can switch environments in the terminal window or using the environment picker in the lower left, but it there doesn't seem to be a way to quit the current kernel and have it re-launch under the new environment. I've tried using the "Restart Kernel", closing the notebook and re-opening.
Is there a way to do this?
I'm a developer on this extension. The intention was for this feature to function as the Python Interactive Window did, where you could use the VSCode Interpreter picker to change out an open notebook to a new kernel. However it appears that we have a hitch that we shipped with this functionality. There is already an issue open in our github here which I believe that you filed (just going on user name match :)):
https://github.com/microsoft/vscode-python/issues/7862
That will be the right place to track our progress on fixing this, and it's on our immediate backlog.
Related
I am trying to connect to a different environment for jupyter notebook in VS Code. I have settings.json as in the following:
"python.defaultInterpreterPath": "C:\\Users\\username\\.conda\\envs\\analytics\\python.exe"
I have manually added python path in select python interpreter
I have tried almost every solution, but I am unable to change kernel. Whenever I Reload Window it selects the intended kernel for a few seconds and then it changes back to base. I have never encountered this problem before, I have just installed anaconda and VS Code on this system. Can someone help me with this problem?
I just pressed that triangle to run the code. I want that button to work because I want to use the debug mode from that button. When I click it, it tries to run three times and it somehow got into anaconda. I checked Python default interpreter path in preferences>settings and it is set to C:\Users\ucanc\AppData\Local\Programs\Python\Python39\python.exe, not the anaconda one. I am pretty new to this and I do not know what is going on.
edit: It seems like it is running as WSL termial that is why it has name#LAPTOP-xxxx:/mnt/c/ in the front.
I am having issues with changing the starting folder of Jupyter notebooks, as I would like to run the notebooks on a shared server. I am running Windows 10. I have already tried several of the options online:
I have tried changing the "Start in" property of the jupyter
shortcut: now the shortcut just quickly opens the terminal, then
immediately closes again and nothing more happens.
I have tried running the "jupyter notebook --generate-config"
command, both in and outside python: in the first case it tells me
that jupyter is not a recognised command, and in the second that
there's a syntax error at notebook.
I have made a .bat file with the instructions of the shortcut ('''C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\python.exe
C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\cwp.py
C:\Users\USERNAME\AppData\Local\Continuum\anaconda3
C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\python.exe
C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\Scripts\jupyter-notebook-script.py
Z:\Test''') but it
simply opens the terminal in python, and nothing more.
If I try to launch jupyter from the anaconda interface it works, and I can also start it from the terminal, but not in any other way.
The "jupyter notebook --generate-config" method, explained well in this answer from #marneylc, worked, I just had to start in the Anaconda Promt, rather than in cmd.
I hope this is the right way of answering my own question...
In R Studio, Matlab, and in some Python IDEs (like Thonny) you can see a list of the variables in your environment, together with some summary information like values, type etc.
Is there a way to do this in VSCode without going into debugging mode?
Seems like the closest as it gets to the RStudio Environment window is by installing Jupyter. Then you can type #%% in your .py file and a small "Run Cell" button will appear. Running the cell will open the "Python Interactive Window". There you can click the "See Variables Active" button to open up the Variable Window and see your variables... still a bit painful in comparison with RStudio, this should be integrated in VScode's IDE.
See steps here:
https://code.visualstudio.com/docs/python/jupyter-support-py#_variable-explorer-and-data-viewer
VS Code has an IPython mode with a dropdown box called Variables that basically does exactly this.
To enter IPython mode all you need to do is highlight a piece of code and hit Shift+Enter
The first time you do it there might be a bit of setting up to do but it was pretty easy to get it working on my Mac. Not sure what it's like on Windows/Linux though
Note: When I use VS Code I open it from the terminal (simply enter the command 'code') after I've activated my conda environment. That way the IPython interpreter uses my preferred conda environment when it launches.
I am trying out IntelliJ. I have installed the Python plugin, and IdeaVim.
I cannot navigate properly across Jupyter Notebook cells using hj. I mean, on normal mode, I cannot go to the next (or previous) cell, even if there is one, using hj.
Is there a way to do it without the mouse, possibly rebindable? I have read the tutorial and tried to find something in the program, but could not.
Ideavim plugin doesn't seem to support Pycharm's notebook implementation as of right now :(
There's an open issue marked as "bug" on Ideavim's issue tracker that was opened back in 2015 and it seems like it doesn't have any progress made since.
However according to the comment in the issue thread you can:
funny way to get into the command mode is type something so that the suggestion panel appears, now press "esc" you will get into Vim command mode
So this might indicate that this could be solved and updated in the future.
As an alternative you can try out jupyter-vim-binding, however it doesn't work with Pycharm either.