skip to Main Content

enter image description here

I tried running ensurepip in VScode and it kept on showing this command line does anyone know why? Or is there any other way to download pip and set it to VScode?

I also tried to download the pip document from curl but it still didn’t work and where normally should u put pip document under? it just kept on saying that there was no pip but when I tried to download it it says it already exist but does not execute any pip command

2

Answers


  1. You can use python -m pip to access the pip installation associated with the globally installed version of python on your system.

    If you wanna access pip globally you gotta add the path to your pip installation to the PATH environment variable, or setup a python virtual environment in your project location and activate that first instead – see How to use virtualenv with Python?.

    Login or Signup to reply.
  2. A nice and efficient way to keep things organized is by using virutal environements. Here is how to do it in VSCode.

    Open your project’s directory in VSCode
    and close all terminals, click on the trashcan icon to kill all the terminals.

    VSCode Terminals

    Then open a new terminal by doing: ctrl + shift + ~

    now inside your project directory type the command:

     python -m venv venv
    

    This should create a virtual environment for your project. You can then tell VSCode to use that environment.

    Change the python interpreter in VSCode by doing ctrl + shift + p
    and searching for >Python Select Interpreter including the less than sign.

    VSCode Python Interpreter

    Select the .venvScriptspython.exe and reboot the terminal using the trashcan.

    Now try to use python -m ensurepip and it should work as intended.
    You will have to install all the packages manually unless you’re using a requirements.txt file

    Whishing you the best of luck to resolve your issue.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search