Pip installing packages in wrong place

I am using Python 3.12.3 on Windows 11 and VSCode. While working on a project in VSC, if I type “pip install requests”, the requests package is installed in C:/…/Python/Lib/site-packages instead of C:/…/Python/Python312/Lib/site-packages . This is intimately related to fact - Python 3.12 is creating a new folder(named Python312) inside the existing Python folder. While I was using Python 3.11, this was not a problem.

Please help.

I have installed python again by using custom installation and let’s hope it works better this time.

It is very common to have two installations of Python on a computer and in this case it looks like one has pip in your earlier in your system path than the other.

The recommendation to prevent this is to use

python -m pip install requests

The -m flag executed a module like a main, by calling it via the python command you are guaranteed to pick up the version of Python you are using.

Ya, got it.

If you’re using Windows, the recommendation is to use the Python Launcher py.

1 Like