Microsoft Visual Studio Properties - python

Recently cloned the spyder.py source from github searching for a python api; been going through the files in Powershell looking for a desktop python editor to edit code and run tests.
Most of the files run so far (using the '.\ -filename.file extension-' command) have opened windows briefly on screen which then exited.
Would anyone with experience on Spyder care to explain the method for best editor use (or the file to run to get access to the editor)?
Respectfully,
HeiwajimaSidekick22

Related

Viusal studio code can't run any programing language

My vscode can't run any code.I've been trying to fix it for 2-3 days now but that doesn't work.I don't know it about I try to setup c/c++ in vscode about 15 days ago that time it work it can c c++ python however this few day I back to code something and have found can't run any code.
can anyone please suggested solutions.I read previous post about this before but it not the same when I try to run code noting happening and no error.
and about python files must call file like this for run and that file must in Drive C.It unlike normal just press F5 or click runcode then it run.
I want to fix it like before.It mean make it to show the result of my code in visual studio.
If you can't run any code inside VSCode it's most likely the lack of needed extensions causing the problem, you can download extensions by going to the extension menu with ctrl + shift + x and if you are connected to the internet, VSCode will show recommended extensions for you.
About the problem that you can't run a python file outside of the C: drive, I think that the anonymity of your python executor to the CMD is causing this problem.
The easiest way to fix it is to uninstall your python executable with its own installer (the setup.exe file which you installed python with, it can uninstall python too) and installing it again with the difference that you must tick the "add to environment variables" option at the beginning of the installation, then you may be able to run the python executable everywhere with this command:
python example.py
After installing c/c++ extension you might want to go to the extension you downloaded and look under the extension name for other c/c++ extensions you want to install too.
To make intellisense and built-in c/c++ code execution work, download Microsoft's c/c++ extension for the best experience.
May this help you!
Trial 1: Try downgrading your vs-code version and check if problem still persists.
Trial 2: Assuming you don't have code runner, Try installing code runner extension in vs-code and use that for running your program

Accessing and running Developer PowerShell using a Python Script

I am trying to create a python script to automatically run unit tests in Visual Studio. One path that I am exploring would involve using shells, in particular Developer Powershell. I am running into a roadblock with accessing this shell, though. Here's what I have so far:
First off, the Visual Studio solution has all of the necessary files; I just need to build and run, which I can do in Developer Powershell using the following lines
> MSBuild.exe .\project.sln
> VSTest.Console.exe .\x64\Debug\project.dll /Logger:trx
To get to Developer Powershell, I can type the following into a normal Powershell:
> C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -noe -c "&{Import-Module """C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"""; Enter-VsDevShell 64375397}"
And if I need to start from CMD for some reason, I can get to Developer Powershell by simply typing this:
> %comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat"
My issue is trying to put all of this in a python script. I can open Developer Powershell using os.system, but then I can't use os.system again until I exit Developer Powershell. Is there a way to let the python know that I am in a new shell and to start interacting with that one?
Okay, I figured it out, but I'll just leave this all up in case anyone has a similar question:
MSBuild and VSTest.Console are both just .exe files, and as such just have their own locations that you can target in a shell (links on where to find the are below).
MSBuild
VSTest
If you just run > & "C:\<The_path>\MSBuild.exe", it'll work fine with the arguments above. No Developer Powershell needed.
You can even use this stack exchange question to generally find the .exe files on any Windows system.

Python in Visual Studio Code without PowerShell

So I need to use Python for my work. Unfortunately, since recent hacks, the companies security policies are very strict and there is no way I'm getting admin rights. I managed to persuade our IT to install Python, Visual Studio Code, and the Python extension for it on my computer.
If I try to run python commands in the Python interpreter it works. But when I try to run a Python script in Visual Studio Code it hast to run Power Shell which is also blocked for security reasons.
I get the following error:
The terminal process command 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe' failed to launch (exit code: {2})
Is there some way around this? To use Python in Visual Studio Code despite all of the security restrictions?
I tried asking our IT department but they have no idea how to help me...
Thank you in advance.
You can change the VS Code settings and tell it to not use PowerShell as shell in the integrated terminal.
For example, I have put Windows Terminal in there, but you can also use CMD or any other shell such a git bash as long as it's available in your system.
Press ctrl+shift+p and type/select Open Settings (JSON). Then add some of the following to this configuration file, and save.
For Windows Terminal:
"terminal.external.windowsExec": "C:\\Users\\<your-username>\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"
For CMD:
"terminal.external.windowsExec": "C:\\Windows\\system32\\cmd.exe"
I'm used below code in setting file and it works.
"terminal.integrated.defaultProfile.windows": "Command Prompt"

Basepath argument is not fully qualified. Parameter name: basePath. I can not use code completion

I just open a .py file on visual-studio-code. And I got a message:Basepath argument is not fully qualified.
Parameter name: basePath. And I can not use python completion. The source of this message is Python(Extension) of Microsoft.
Here is image description
I had the same issue today, and I opened a folder in VSCode(The path of you .py file. You can see the option in your image). It seems that it works for me now. I'm not sure whether it will be helpful to you.
Same thing happened to me, it started today.
I checked my Python install, python path in sys, reinstalled VSCode and no changes.
Im using Python 3.7, win 10.
In the end what solved it for me was in settings.json, in VSCode, set "python.jediEnabled": true and after that VSCode prompted me with a warning that one of the extensions uses the language server (sorry i forgot the name of the extension, it was an old python autocomplete extension), after removing that extension everything was working fine.
As far as i understand it was a problem with the ms language server, jediEnabled setting configures the VSCode to use Jedi as the IntelliSense engine instead of Microsoft Python Language Server, some extensions require ms lang server so if you remove them you should be good.
Give it a try, hope it helps.
I had the same issue yesterday and solved it this afternoon.
The source of this message is also Python(Extension) of Microsoft.
But, and i assume this is maybe the same for you, it was linked to "IntelliCode extension for VS Code (preview)" which asked me to activate pylit.
So the only way i found to repair the software was to delete my preferences files to reset Visual Studio Code and boot like the first time.
Then i re-installed my extensions and preferences.
You do not need to uninstall the soft.
Note that uninstalling Visual Studio Code won't change anything if you don't delete manually the preferences files.
Here how to do it on Windows :
https://filljoyner.com/2018/08/18/how-to-reset-visual-studio-code-on-windows/

How to debug Python running on a local lighttpd server using Python Tools for Visual Studio (PTVS)

Visual Studio has great python support via the Python Tools for Visual Studio:
http://pytools.codeplex.com/
Debugging python code in Visual Studio works as expected. I set up a lighttpd server on my local Windows machine, and I have python scripts running as cgi scripts. I would like to be able to debug these in Visual Studio (running on the same PC) when running from lighttpd.
I am able to debug the cgi scripts using:
http://winpdb.org
But I would prefer Visual Studio.
According to this question:
How to debug a remote python application with (Python Tools for) Visual Studio?
It is implied there is almost a way, but I don't see a specific way to set a breakpoint and have it debugged in VS.
Figured it out. This does work, and works pretty well, once you get the steps down.
Add a delay to the python source file like this:
time.sleep(10)
This is necessary if you are not using FastCGI, as the python process is probably going to start and finish long before you can attach to it. I assume this would be different with FastCGI, but I haven't reached that stage yet.
Set a breakpoint in your python file that is running in your lighttpd (or apache?) server. I tested lighttpd. Note: If you don't add the source file to a project in VS, and thus don't set a breakpoint, you can still debug, but you'll have to force an error in the file. I added a line 'debugger' which worked.
Load the page in a browser and allow the delay to be hit
In VS: Debug -> Attach to process -> pythonw.exe (complete this before the delay elapses)
I added a short macro to the Visual Studio IDE that automates the procedure of attaching to pythonw.exe. I'll share that if anyone is interested.

Categories

Resources