What do I need to put in this file in order to run my program. From the command line normally I navigate to the folder (as my test file is there too) and type:
python main.py test_file.xlsx
So my python script is called main.py and I am sending an excel file as an argument. I can't work out what you are supposed to put in the launch.json file to get it to work I found the args bit from another post, but I have no idea if I have done it correctly as vscode is objecting to its own default launch file comment?:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"args"
"console": "integratedTerminal"
}
]
}
Completely lost with this, why is there not some documentation around this?
Let's start from the top:
The JSON you have pasted above is not valid - objects must be key-value pairs. Your args key does not have a value.
args is an array of strings that are passed in to the command in your configuration. In your case this would be ["${workspaceFolder}/main.py"] if your main is in the root directory of the workspace.
To have a nice dynamic list of secondary arguments (in your case files) you can use the runtimeArgs key. It is also a list of strings, in your case it would be ["test_file.xlsx"]
Documentation about the VSCode debugger can be found here: https://code.visualstudio.com/docs/editor/debugging
Hope this helps :)
Related
I created a python notebook in Azure Data Studio and it is working as intended. I saw an article about being able to run notebooks as jobs with an extension. These notebook jobs create a PowerShell script that is executed as a sql agent job. It seems as though this only works with SQL notebooks and not python notebooks based on the error I am getting. For example, I get an error message about the from clause with "from sqlalchemy import create_engine"
However, the PowerShell script that was created contains the kernel and the language meta data, so it almost seems like it should work. But then again, I also don't know much at all about PowerShell.
"metadata": {
"kernelspec": {
"name": "python3",
"display_name": "Python 3 (ipykernel)",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.8.10",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
}
},
Does anyone know if this is possible? Seems like there could be a work around. It would be a game changer to be able to run python notebooks from SQL Server.
Here is a simple test I did.
I created a python notebook with
x = 5
y = "John"
print(x)
print(y)
The error I get, is exactly the same error as if you try to run that in SSMS
"Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '='.
The name "x" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
The name "y" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted"
Thanks for your time
IN VS CODE i get the error "include file not found in browse. path."
with an error squiggle under my header file #include <stdio.h>
how can i make this library accessible to my code.
all i have is a folder and a main.c file
Very new to all this, the other answers seem to be out of my depth as im not sure what files they're accessing.
Thank you in advance.
Very similar problem to the one posed here, and thankfully a very similar solution.
Ctrl-Shift-P will open the "command bar", start trying C/Cpp: Edit Configurations until it's the top result then hit enter, this will create a c_cpp_properties.json file in the .vscode folder of your current project directory (making this configuration unique to this project, so you'll need to repeat this for other projects). This json file has sections for Mac, Linux and Win32, edit the section relevant to you or all if you know the paths for the other platforms. Each block has a name, includePath, defines, intelliSenseMode and browse property. The browse property has a child array called path (which is what we're looking for, include file not found in *browse.path*), add the paths to your include directories here, one string each, and remember to use forward slashes even if Windows gives you them as backward slashes.
While the offending error disappeared when adding the correct path to browse.path, I also added it to the includePath section because according to the hover tooltip includePath is used by the intellisense engine whereas browse.path is used by the tag parser. Can't hurt to have both set up correctly.
Attaching example of .vscode\c_cpp_properties.json file with browse.path which solved my issues with Arduino dependencies
{
"configurations": [
{
"name": "Win32",
"includePath": [
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\AzureIoTProtocol_MQTT\\src\\**",
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\AzureIoTUtility\\src\\**",
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\AzureIoTHub\\src\\**",
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\WiFiManager\\**",
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\ArduinoJson\\**",
"C:\\Users\\localuser\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\**",
"C:\\Users\\localuser\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.2\\**",""
],
"forcedInclude": [],
"browse": {
"path":[
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\AzureIoTProtocol_MQTT\\src\\**",
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\AzureIoTUtility\\src\\**",
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\AzureIoTHub\\src\\**",
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\WiFiManager\\**",
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\ArduinoJson\\**",
"C:\\Users\\localuser\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\**",
"C:\\Users\\localuser\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.2\\**"]
},
"intelliSenseMode": "msvc-x64",
"compilerPath": "C:\\WinAVR-20100110\\bin\\avr-gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17"
}
],
"version": 4
}
All you need to have is, to check if browse.path exists in the c_cpp_properties.json file. If not include this part. It should fix the issue.
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "gnu++14",
"intelliSenseMode": "gcc-x64",
"browse": {
"path": ["${workspaceFolder}"],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4 }
Hi i'm new into vscode and when i run a program there is some text that i want to get rid of.
i mainly want to remove the first two paragraphs, but also removing the path would be ideal
i tried code runner but thats not the solution i'm looking for
i also tried changing the color to black but i reckon there is a way to remove it
Adding the "-NoLogo" start parameter will remove the paragraph of text; If you open your settings file (Ctrl+Shift+P and then type "Settings" -> User Settings JSON), you can use the following bit of configuration:
// should go in the main JSON object with the other keys
"terminal.integrated.profiles.windows": {
// it might generate some more profiles automatically, but powershell is what matters
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell",
"args": ["-NoLogo"]
}
}
I believe by default those lines will always appear because those are the one that show up when you open cmd on Windows.
Also, by default, the path open to the current project folder, that the reason why you see the path.
You can do a cls to clear the terminal, but the path will remain unless you change the directory.
You can read more about VS Code integrated terminal here and about terminal profiles here
First go to terminal settings and then the add -nologo arg
I want vscode to render lambda as λ in my editor. I do not want it to replace the word with the symbol, as that will just break my code since Python doesn't interpet λ as a keyword. It needs to purely be a rendering change, with the actual code still being lambda.
Are there any extensions that do this? Is it possible within the VSCode environment to do this?
The extension Prettify Symbols Mode allows you to do this. You'll have to edit your settings.json to specify this particular subsitution. To do this install the extension then go to the extension's settings page -> "Prettify Symbols Mode: Substitutions" -> edit in settings.json. Then add this:
"prettifySymbolsMode.substitutions": [
{
"language": "python",
"substitutions": [
{
"ugly": "lambda",
"pretty": "λ"
},
]
}
]
to the file.
There are more complete options and details available on the extension's page, and here is a more complete example of a Python config (with a lambda expression).
I believe other people might have asked similar questions, I don't know if I'm cross posting this, if so, I apologize and will be very appreciated for some hints or links that can guide me through this.
I'm new to sublime text2 but have being using IDLE for python scripting for a while.
The question here is quite simple. so here is the thing.
In IDLE, after I wrote a script and run it with F5, the script will run in a python shell like this:
and I was able to retrieve some of the avriables I defined in my script that was running after the shell finish running the script like this: adm_pop is a dict type I defined in my script.
this is very handy since every time I ran the script I was able to check whether one or two variables were declared correct and value assigned to it is correct. But in sublime text I wasn't able to do this since after the script finished running it just finished. like this:
I wasn't able to do any other input with the console like I can do with IDLE. It's just bugging me a lot so hopely you guys can give me some hints. Thanks in advance!!!!
Go to your Packages folder by selecting Preferences -> Browse Packages.... Go to the User folder and create a SublimeREPL folder containing a config folder containing a Python folder. Then, within that final folder save the following as Main.sublime-menu:
[
{
"id": "tools",
"children":
[{
"caption": "SublimeREPL",
"mnemonic": "r",
"id": "SublimeREPL",
"children":
[
{"caption": "Python",
"id": "Python",
"children":[
{"command": "repl_open",
"caption": "Python",
"id": "repl_python3",
"mnemonic": "p",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["c:/pythonXX/python.exe", "-i", "-u"],
"cwd": "c:/whichever/path/you/want",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
}
]
}
]
}]
}
]
Change the path in "cmd" to the correct one for your Python installation, and feel free to customize the "cwd" (Current Working Directory) path to whatever you want. This will create a new menu option under Tools -> SublimeREPL -> Python that will be protected from any package upgrades.