Skip to content

Forum in maintenance, we will back soon 🙂

Can't Run Python sc...
 
Notifications
Clear all

Can't Run Python scripts

5 Posts
4 Users
2 Reactions
81 Views
(@google-rayazsiddiqi)
Posts: 95
Estimable Member
Topic starter
 

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?

@admin @ssadvisor 

 

 
Posted : 04/29/2024 5:54 pm
(@husein)
Posts: 464
Member Moderator
 

@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.

 
Posted : 04/29/2024 6:46 pm
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

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

 
Posted : 04/30/2024 12:05 am
Hasan Aboul Hasan
(@admin)
Posts: 1208
Member Admin
 

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
 
Posted : 04/30/2024 8:05 am
(@google-rayazsiddiqi)
Posts: 95
Estimable Member
Topic starter
 

@husein thanks this fixed the problem!

 
Posted : 05/07/2024 5:22 pm
Share: