Visual Studio Tools for AI - Variable Explorer not loading - python

Installed VS Tools for AI and tried to run a python deep learning script.
The script runs well on the Anaconda Interactive provided by the IDE. Problem is with the 'Variable Explorer'. It shows an error saying "Error retrieving environment list".
The Default python environment is set to Anaconda 4.4.0.
Any solution to get the prevailing variables in the executing script through the explorer?

(The comment from Jespar is correct, so promoting it to an answer.)
That Variable Explorer belongs to R tools, so it will only work when you are using R.
There is currently no variable explorer for Python in Visual Studio, so this will not work. The two options to inspect variables are to debug a script (set a breakpoint and use the Watch/Locals windows), or use the interactive window (and the normal Jupyter-style commands, if you've enabled "IPython interactive mode" from the Python Environments window).

Related

VS Code and Jupyter notebook problems with the python interpreter

Im currently doing a project in VS Code using Jupyter Notebook, however I have some problems with the python interpreter. The problem seem to do with VS Code using two different interpreters.
I have chosen, what I think is the right interpreter, in the upper right corner, namely
However, when I check what version of Python is used in the terminal, then my version is 2.7.17, whereas it should be 3.8.5. I have already tried restarting the kernal, VS Code and changed between other interpreters. I dont know if it has something to do with the Julia env. as shown below:
Can anybody help me understand the problem, and maybe a fix?
The vscode integrated terminal uses the built-in powershell or cmd of windows. If you type python in the terminal, it will open the interactive terminal of the python version pointed to by the system environment variable. What you choose in the upper right corner of jupyter is just the jupyter notebook kernel, not even the python interpreter for vscode.
Ctrl+Shift+P to open the command palette, search for and select Python:Select Interpreter, then select the interpreter for the python file.
Of course, this operation is only valid for vscode. If you want the terminal to also use the interpreter you selected for vscoe in the Select Interpreter panel, use a virtual environment. When you activate the virtual environment in the vscode terminal, typing python will open the python interactive terminal under the environment.

Unable to change Python 2.7 to Python 3.8 on Sublime and VS code

I have been trying to change my python interpreter on sublime text and VS code and no matter what I do, both of them refuse to change. It always picks the default Python 2.7 version.
On sublime, I tried to create a new build tool, added the path to Python3 but nothing is working.
And on, VS code, even if I select Python3 from the drop-down menu, it doesn't change anything.
I changed the system's default python interpreter from 2.7 to 3.9 and set the path on bash profile. It fixed the issue for me.
I don't know about Sublime, but for VS Code, there looks to be quite a few things to verify:
Check your User Settings on whether you've set up a default interpreter for your applications
Are you using Window 10 WSL? Then you might want to check out issue 3227 for vscode-remote-release where the comment was:
So I was having this same exact issue until I read this article on a wsl tutorial. In there it says we should have "Remote - WSL" extension installed (already did). In the bottom left corner "Remote - WSL" installs a status button that has the "greater than" and "less than" symbols displayed. If you click that button and tell VSCode to open up in the remote WSL distro environment it fixed my issue where vscode was unable to find an interpreter for python.
For Sublime, you need to hit ⌘B with your script pane focused in order to use your new python3.sublime-build build system.
It looks like you are running your script within Terminus, which is fine, but you need to use the python3 command when running it from the command line, even if that command line is within Sublime.
Please check out my answer here on how to make a Python build system that accepts user input, as the Sublime "console" doesn't allow you to interact with your program. Since you already have Terminus installed, I'd recommend going down to the bottom of the answer and using the Terminus build system. That way, you won't have to deal with Terminal windows opening every time you run a build.
The terminal window uses your PATH, not the IDE settings, so manually typing out python --version isn't testing anything except the PATH variable
In order for the terminal to use the "correct" python binary you've specified, it would need to give the absolute path to it, which I believe using Command+B (using the build options) in Sublime would do. Similarly, you can use the Run/Debug Configurations in VSCode.
Or you can modify your ~/.zshrc to fix your PATH, for example installing pyenv to change the entire system Python version, or the one for the current folder

Arrow up / previous command in VSCode Python Interactive not working

I'm working with VSCode on an Ubuntu 18.04 machine. Everything is fine except that I can't get back to the previous command in Python Interactive Window via Arrow Up. It works in the integrated terminal though, integrated shell is /bin/bash.
I have no idea where this is coming from. I changed "keyboard.dispatch" to "keyCode", but that's not the problem. I also tried different versions of the python-extension.
Do you have any idea?
Thanks!
Not sure if this is helpful for you as an Ubuntu user, but I came across the same problem in Windows this week. In my case, the issue cropped up after I installed the Python extension in VS Code (or at least I didn't notice the issue before this). The combination of using the Python extension, Git Bash for terminal, and python virtual environment killed the up arrow feature for me. Using python outside a virtual environment works fine. My solution was to use Command Prompt as the terminal when I wanted to use a virtual environment interactively.
In my situation, although I delete all the shortcuts of UpArrow, I still can get the previous command through UpArrow in Python interactive. This means there's no way to configure this shortcut, it was built in the plugin which built in Python extension.
So it's some problem with your Python extension, but you said you have tried to install a different version of Python extension but still not work. Make sure you have deleted it completely -> delete the extension folder manually(it's under C:\Users[UserName].vscode\extensions\ms-python.python-xxx).

Go to Definition in Python Microsoft Extension is not working in modules

I have installed
Python 2.7
Visual Studio Code 1.471.
Python Extension 2020.6.91350
While Go to definitions works within same module, but if we import some other module, Go to definition don't work
Any idea what can be solution for this ?
TL;DR: Your language server might not be opening up properly because vscode version is not up to date. This goes to all languages
If your symptoms include
Type >Python: Show output in vscode console
Restart vscode and open any python file
In the output if you see any line saying something close to Error: cant't start language server because vscode version low
You need your vscode updated to latest version.

Different default terminals by language in VS Code

I am using Visual Studio Code in Windows 10 to code both in Fortran and Python. When compiling in Fortran, I use Ubuntu's WSL Bash terminal through the Windows subsystem for Linux. When running Python scripts, I use either the Powershell or the Windows command prompt.
I know that in VS Code I can have a default integrated terminal in Terminal: Select Default Shell.
Within VS Code, I have used WSL Batch for Fortran, and the Powershell for Python. My problem is that I have to manually select the terminal I want depending on the language I am working.
Is there any way of setting different default shells for different languages? So that, when compiling Fortran I could automatically get WSL Bash, and when using Python I could get the Powershell? Maybe setting a rule by file extension?
As suggested by #frode-f, if you can create separate workspaces then you specify the settings per workspace. Basically just separate the code into individual directories and then open those directories separately in VS Code. I don't know if multi-root workspaces will get you what you want since that's still a single VS Code window.
Otherwise open two terminal instances in VS Code using different shells and flip between them as necessary.

Categories

Resources