1

I have been using Visual Studio Code to run Python for a few months, but recently when I select Run Python File or Run Python File in Dedicated Terminal, a new instance of PowerShell opens in the terminal and the current folder is printed, but nothing else happens.

I have tested this with different folders and files, and I have the same issue. However, if I run Python using the global environment instead of my venv, it does work. Also, running the file with Python Debugger: Debug Python File or Run Current File in Interactive Window works.

What could be causing the issue or where could I look further?

1 Answer 1

0

I'm not very experienced yet, but I can share a few ideas here.

First, are you using the Visual Studio Code terminal? You could try using the real one. If you don't know how to: run cd /pathtoyourfolder/, and it should change the working directory into your selected folder. Then, activate your venv by: source .venv (or path if it isn't in the working directory)/bin/activate.

Then run the file by: python3 nameofthefile.py. I do this in the real Terminal, but you can as well run this in the VSCode integrated one. Check that the venv is activated: (.venv) before the name of the working directory.

PS: I remember the fact that in my very first scripts I selected something like {run selection line}, and it printed the file in the terminal and I had to press return and invoke the function, but that was because there wasn't a main function that ran. Could you precise what type your file is?

New contributor
zulu27 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.