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
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?.
A nice and efficient way to keep things organized is by using
virutal environements
. Here is how to do it inVSCode
.Open your project’s directory in
VSCode
and close all terminals, click on the trashcan icon to kill all the terminals.
Then open a new terminal by doing:
ctrl
+shift
+~
now inside your project directory type the command:
This should create a
virtual environment
for your project. You can then tellVSCode
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.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
fileWhishing you the best of luck to resolve your issue.