'Where does pipenv install packages?

I'm using vscode, and my editor shows:

enter image description here

The red is showing that it can't import those packages. I'm using a pipenv virtual environment and for the life of me, I can't figure out where it installs the packages.

If I could, I could just add that to $PYTHONPATH and life would be better.

Any help?



Solution 1:[1]

pipenv installs packages in ~/.local/share/virtualenvs/

To find the complete path, run pipenv --venv

Solution 2:[2]

On windows machines start pipenv pipenv shell then where python to get the path to your scripts

Solution 3:[3]

I spent like 2 hours trying to figure out what I was doing wrong (the files would run but the imports would not resolve). Turns out it's surprisingly simple.

Go to the root of your project & open up a new terminal. Use the following commands to open a shell and get the location of the virtual environment.

>>> pipenv shell
>>> pipenv --venv

C:\Users\gasma\.virtualenvs\dungeon-generator-MV179gUf

If you open up this in the file explorer, you'll find exactly where the modules are being installed.

where tf are these modules

From here, you can create a new .vscode/settings.json file (still in your project directory) to let VS Code know what's up.

In my case, I typed this in:

{
    "python.autoComplete.extraPaths": ["C:/Users/gasma/.virtualenvs/dungeon-generator-MV179gUf/Lib/site-packages"],
    "python.analysis.extraPaths": ["C:/Users/gasma/.virtualenvs/dungeon-generator-MV179gUf/Lib/site-packages"]
}  

Make sure your replace the file paths with the one you got from running pipenv --venv. To run your project, just use python <file>.py, and to exit the virtual environment, simply type exit.

Solution 4:[4]

/Users//.local/share/virtualenvs//lib/python3.9/site-packages

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Isaac Sekamatte
Solution 3 Ad Charity
Solution 4 feng