In .vscode folder where your workspace settings are included set your location of python and pipenv package as follows
{
"python.pythonPath": "/Users/farhansaeed/.local/share/virtualenvs/ga_loader-8xg8-7fK/bin/python",
"python.pipenvPath": "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true
}
In Mac OS I have to put it there so that vscode knows where all virtual enrionments are and allocate the one associated with project workspace in status bar (python 3.6.8 64 bit ('ga_loader-8xg8-7fK':venv))
"python.venvPath": "/Users/farhansaeed/.local/share/virtualenvs/",
- Also set pipenvPath as above to suppress below message in vscode
"Workspace contains Pipfile but 'pipenv' was not found. Make sure 'pipenv' is on the PATH."
- Also add following in .zshrc
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:$PATH"
# This path needs to be defined to use python 3 and avoid system python 2.7 in mac/linux based systems.
PATH="/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages:$PATH"
# This path needs to be defined to suppress vscode "Workspace contains Pipfile but 'pipenv' was not found. Make sure 'pipenv' is on the PATH." message.
PATH="$HOME/scripts:$PATH"
export PATH
For Python :
- Usually this paths depends on your installation location of bin/python.
- Location can be found by writing 'which python3' in iterm2 (depending up alias python = 'python3' is set) otherwise it will point to mac os system python 2.7
- We can use two paths either python installation path /Library/Frameworks/Python.framework/Versions/3.6/bin/python or path inside virtual environment which I have given in my example. (after activating virtual environment inside my project.)
- This python path inside virutual environement can be found by doing 'which python3' inside activated virtual environment.
- Make sure your python 3 installation location is in $PATH too for pipenv to use python 3 while creating virtual environemnt.
For Pipenv :
We need to find the location of the pipenv package. location of pipenv that 'which pipenv' gives still not remove vscode message and it provides following location which is not correct.
/Users/farhansaeed/.local/share/virtualenvs/ga_loader-8xg8-7fK/bin/pipenv for activated virtual env.
/Library/Frameworks/Python.framework/Versions/3.6/bin/pipenv for not activated virtualenv
This location is
**/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages**
and this can be found by running at ~ directory or any location
/Users/farhansaeed > pip install --user pipenv
This will give following location if its already installed.
**Requirement already satisfied: pipenv in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (2018.11.26)**
I didn't have to place pipenvPath variable to suppress the annoying message of pipenv not existing.