Configure the path of the default "run in terminal" option - visual-studio-code

I've recently tried running my Python project in VSCode.
I have in my code imports from other files withing my project. The problem is that when I try running it from the default "play button"/"run in terminal" option, it does not detect my other files. (I opened the entire project's folder, as well as created a workspace with it))
When I created a debug configuration, this line was added automatically:
"env": {"PYTHONPATH": "${workspaceRoot}"}
which enabled the requested import.
I was still not able to figure how to make it work with the default "play button". (e.g see what run configuration it uses, etc)
Thanks for your help! <3

The fix was adding:
"terminal.integrated.env.windows": {"PYTHONPATH": "${workspaceFolder}"}
to settings.json and restarting VSCode

Related

VSCode not creating launch.json file

I'm debugging a project in VSCode using msvc. When I run the debugger, VSCode asks me to choose an environment and I choose the "C++ (Windows)" option:
Then it asks me to select a configuration:
I choose the "cl.exe build and debug active file". Everything runs correctly and it creates the ".vscode" folder with the "tasks.json" file in there for the next time I try and build the project. It DOES NOT create the "launch.json" so every time I want to run the debugger I have to select the configuration again. In previous projects, the "launch.json" was created with the correct configuration here:
Why is vscode not creating the "launch.json" file? Am I missing something?
According to the VSCode documentation on C/C++:
When you debug with the play button or F5, the C++ extension creates a
dynamic debug configuration on the fly.
There are cases where you'd want to customize your debug
configuration, such as specifying arguments to pass to the program at
runtime. You can define custom debug configurations in a launch.json
file.
To create launch.json, choose Add Debug Configuration from the play
button drop-down menu.
Example
Source:
Configure VS Code for Microsoft C++

How to disable auto generated config file for project?

For each project (with Git enabled), VSCode auto generate a project specific config file called .vscode.
How to disable this behavior?
Maybe some extention is doing it? It shouldn't create folder unless workspace settings were changed or created runner or tasks or debug.
Look what's inside that settings.json file.
Try to run vscode without extentions.
You can also exclude it from explorer:
setting.json (ctrl+,) >>
"files.exclude": {
"**/.vscode": true,
},

Disable Auto Generation of .vscode Folder

I often like to use VSCode to quick view some projects to pull snippets from them. However, this leads to a ton of additional .vscode folders being placed on my drive in any folder I use the right-click -> Open with VSCode option.
Is there a way to disable this folder from being created every time vscode loads somewhere new?
This issue was due to the 'C/C++ for Visual Studio Code' extension being outdated.
Upgrading to the latest version of this extension has fixed the problem.
That is not the standard behaviour of VSCode, normally the .vscode only gets generated once there is something like a launch.json put into it. Mind checking what's actually in there?

Where are Run configurations stored?

I'm running Liclipse 2.5.3 on Mac OS. I renamed my project causing me to lose all my run configurations. When I tried recreating one, it says the file exists. However, there are no run configurations present.
Where are the run configs stored?
The normal location for launches is in the workspace in the
.metadata/.plugins/org.eclipse.debug.core/.launches
folder.
Each launch configuration is in a separate xxx.launch file which is a xml file.
You can also Export and Import launch configurations.
These configrations are located in .metadata/.plugins/org.eclipse.debug.core/.launches, and they are *.launch files.
Note that each workspace has its own .metadata folder.
#greg-449's answer tells you where they are stored, but you might be running into a situation where the launch configs for the renamed project are just being filtered/hidden. In the Launch Configurations dialog, there is a toolbar button to control filtering. Check there if deleted/unavailable projects are being filtered; if so try disabling that option and see if your missing configs come back into view.

Pydev; How Do I Config *all* .py To NOT Run In Ant?

Beginner config question here, guys.
So I am in eclipse, in pydev. Some of my src will run in the python compiler just fine, but others try and run in ant. When I click the 'Run' dropdown in the ones that work, and select 'Run As' I get two options. 'Python Run' and 'Python Unit-test'. When I try and run the ones that try and use Ant, I goto the same menu and it only displays '(none applicable)'
How do I fix this?
I was having the same problem. If you were,like me, trying to run code that you had written in IDLE and saved somewhere. You have to create blank project and import that code into the "src" folder of your project. then you should be able to run the code as python in eclipse.
For example. I had a bit of code I was trying out in IDLE saved in a folder in "My Docs". I moved it to my project "src" folder in "Mydocs/eclipse/projects/" and was able to run it in eclipse. Your paths will depend on where you opted to save your eclipse projects.
You should then be able to select your "Python: run option.
This was the link that helped me with this.
http://www.vogella.com/articles/Python/article.html#installation_python
Read the whole thing and it should help.