I had moved around some python and C++ files using the file explorer to better organize my files, but when I tried to use Visual Studio Code after making these changes, some things were out of place. All of my files now had the U label (unmarked), and I found on the internet that I could fix this by adding the files to the repository using “git add FILE NAME”. The files are now all marked with the A label (added).
After I did this, however, every new Python file I create and run is now running my ‘secrets.py’ file instead.
I tried to create a file called ‘test_plot.py’ with some simple Python (using the command “python test_plot.py”), but when I ran it through the terminal, it actually ran another file called ‘secrets.py’.
How can I fix this? Did I add the files to the repository incorrectly?
Nothing about the status of the git repository should alter how your scripts run when invoked like this (it is worth looking into how versioning with git works if you’re going to use it with vs code in the long term).
It sounds like you have a set of local files and you’ve added them to the staging area of this repo, this shouldn’t affect the files at all.
What happens when you run the same command with the full file path instead of a relative path?
What about with a different terminal?
Have you checked the contents of the file
test_plot.py with a text viewer (ideally using the same relative path and then the full file path).
It turns out this issue had nothing to do with the terminal. I was using matplotlib in the file to create a scatterplot, but when I removed the code and used a simple print command, running the file worked just fine. When I used Jupyter Notebooks to run my matplotlib code, it fixed the issue. It looks like you cannot display a scatterplot through the terminal with Visual Studio Code without an extension, so for anyone with the same issue I encourage using Jupyter Notebooks.