Forum in maintenance, we will back soon 🙂
Can't Run Python scripts
Hi, every time I open the VS code window it defaults to this directory:PS D:\github repos\test-repo>
And when I try and run a python script (which has worked before) it gives errors, how can i fix this please?
@google-rayazsiddiqi It used to happen with me when i had all my files messy.
Try organizing every project in a folder and then open vs code and from vs code open the folder it automatically opens all files in the folder and redirects you to its corresponding directory in the terminal.
I also add the -n when starting code. So in your command windows
cd /path/to/project/directory venv/scripts/activate code -n .
With this I'm assuming you've created a virtual environment named venv. To create a virtual environment
python -m venv venv
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
the directory loaded in terminal is usually the directory of the project your opened.
to run the script you need to be in the same directory. as @ssadvisor mentioned, change directory by running this command:
cd /path/to/project/directory
@husein thanks this fixed the problem!