Open command prompt from visual studios and send commands using python - python

I'm on windows 11 and I'm looking to use cmake commands through developer visual studio 2022 command prompt x86 and automate it with python. I have seen that there's a similar post to this one but with c language, their solution was to set the environment variable to VS150COMNTOOLS but that's an older version of visual studio and I don't know how exactly I'll be able to set the environment variable like they did.

Related

Is there any way to use the python IDLE Shell in visual studio code?

I was programming python in Visual Studio Code and every time that I ran something it would use the integrated terminal (logically, because I have not changed any settings) and I was wondering, how could I get it to use the Python IDLE's shell instead of the integrated terminal (which for me is useless)?
I have also got Python IDLE installed in my mac but due to Visual Studio Code having "intellisense", it is way easier.
In VS Code you should be able to select the file which is supposed to be used in the terminal.
Under :
Preferences -> Settings -> Terminal

Visual Studio Code's PowerShell cannot find my Python

For a particular machine learning project, I needed to install Python 3.5 instead of the typical Python 3.6 I usually use. I set up my path variables such that within the command line or PowerShell, python launches my typical Anaconda Python 3.6, but python35 launches my Python 3.5 edition.
My favorite text editor / lightweight IDE to use is Visual Studio Code. However, when I use Visual Studio Code's integrated terminal to execute my Python scripts, it's unable to find my 3.5 edition.
Using Windows Powershell, things work completely fine:
However, when I attempt to access Python 3.5 within my Visual Studio Code PowerShell terminal, it can't recognize python35:
I've Google searched my the error ("the term ... is not recognized as the name of a cmdlet,..."), but every post I found on SO related to this issue (such as this one) has been about setting environment variables. I don't think this is the case here, since my normal PowerShell is able to recognize both python and python35. My suspicion is this has to do with the internal workings of the integrated terminal feature in Visual Studio Code, but I don't know enough to understand what to do next.
Does anyone know why this is happening? It's not a mission-critical issue, since I just pull up my PowerShell to execute my Python scripts, but I'd like to solve it for curiosity's sake.

Does Microsoft Visual Studio Code has its own Python environment?

On my Windows 7 64-bit, I installed Anaconda3 v4.4.0 in C:\Anaconda3, however it could not launch Jupyter (Can't open anaconda jupyter notebook: Network Error (dns_unresolved_hostname)), so I installed Microsoft Visual Studio Code then added python support, now i can run some simple python code such as
p = (4,5)
x,y=p
x
y
z=x+y
print(z)
Now my questions is, does Microsoft Visual Source Code has its own Python environment, or it's actually using Anaconda installed?
Since VS 2017 it comes with an Python Environment itself. So I would say that VS Code uses that and not Anaconda.

Anaconda as default application in Visual Studio

I've just started programming in Python, I use Visual Studio 2015 as my IDE, and I have installed Anaconda, but it's not my default Python environment. For example, when I want to draw something with Python it says "matplot required for draw()".
I changed the path in my computer to "C:\Users\Maryam\Anaconda3;C:\Users\Maryam\Anaconda3\Scripts;C:\Users\Maryam\Anaconda3\Library\bin" and also in Visual Studio in menu Tools → Options → Environment, I change the path to "C:\Users\Maryam\Anaconda3\python.exe" and also I have changed windows and library paths, but still I can't work with Anaconda in Visual Studio. What should I do to solve this problem?
In the Python Environments window, when you selected interpreter, below it is option "Make this default environment for new projects". Press it
Here is an article that might answer your question.
It looks like you should install the free Python Tools For Visual Studio extension:
your default Python installation and installed PTVS, your Visual Studio installation is already set to use Anaconda’s Python interpreter in PTVS.

Microsoft Visual Studio 2015 Interactive window

I'm running Microsoft Visual Studio 2015 and trying to run Python 3.4 - 64-bit but the interactive window shows <disconnected>. If I try to restart it - I get the following error:
Method Not found:'Microsoft.VisualStudio.Text.SpanMicrosoft.VisualStudio.InteractiveWindow.IInteractiveWindow.WriteErro(System.String)'.
I've tried to reinstall the updated and appropriate python tool kit. I've even repaired my installation of visual studio. The interactive window is nonfunctional and I can't type anything into the window. This is true if I change the interpreter to 2.7. Configure interactive window properties doesn't have any options that will connect it to the python interpreter.
Python Debug Interactive also doesn't work and gives the same error.
Right click > Highlighting code > send to interactive, in a .py file that is open (which runs fine) also gives same error.
I believe this is because you need to install a separate interpreter (CPython, IronPython), as described here: https://github.com/Microsoft/PTVS/wiki/PTVS-Installation

Categories