-3

enter image description here

I am trying to set up VS Code for running python and I have installed Python 3.9.6 , the Python extension in vs code, coderunner extension in vs code, and also added the python interpreter path in Environment Variables. Still when I run the simple print code, it gives no output.

Also the pip command gives an error.

enter image description here

Can someone explain how to fix this and keep in mind I am a beginner.

3 Answers3

2

Two problems:

First one:

You have not saved your python file, as it has a white circle on the left in the python file name.

enter image description here

You can add this in the settings.json file:

  "files.autoSave": "afterDelay",
  "files.autoSaveDelay": 1000,

Second one:

You probably have not select pip when you install the python. You can try to install the pip whit this command:

python -m ensurepip
Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13
  • related to the first problem: [Why don't other programs see the changes I made to a file in VS Code until I save those changes?](/q/76984829/11107541) – starball Aug 27 '23 at 06:32
0

Navigate to the correct directory using this command:

cd "path/..."

and then directly try using:

python vscode.py
SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
Savion
  • 1
0

You probably haven't added pip to your system path. But still, you can use pip as python -m pip. Just to ensure pip is installed properly, type python -m pip --version. If you get the correct version info, you can refer to the link below to add it to your system path.

Add pip to your system path

Jyotirmay
  • 513
  • 6
  • 22
  • ok i have added pip to the system path now, but now it gives a different error: PS C:\Users\aryan\Desktop\Computer Science\Python\Python Tutorial Folder> pip Fatal error in launcher: Unable to create process using '"c:\python 3.9.6\python.exe" "C:\Python 3.9\Scripts\pip.exe" ': The system cannot find the file specified. – Aryan Bansal Aug 28 '21 at 09:32
  • 1
    @Aryan: You don't want to add `pip` to the system path. What's needed is to add the *path to the directory* it is in to system path. i.e. `C:\Python3\Scripts` – martineau Aug 28 '21 at 20:20
  • @martineau yeah i meant this only i added exactly what you told into the system path. but it still shows the above error in the comment. also why does vs code show no output when i print ? – Aryan Bansal Aug 29 '21 at 06:26
  • @Aryan: I don't know why nothing it printed—perhaps vs code is not installed or setup properly. – martineau Aug 29 '21 at 07:23