Skip to content

Instantly share code, notes, and snippets.

@farhangithub27
Last active September 1, 2023 08:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save farhangithub27/ff598d29108020a30d49311426428fb6 to your computer and use it in GitHub Desktop.
Save farhangithub27/ff598d29108020a30d49311426428fb6 to your computer and use it in GitHub Desktop.
how to set paths for python and pipenv in vscode and .zshrc file in $PATH variable only for pipenv

MAC OS Catalina

Python Path:

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
}

virtualenv Location

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/",

pipenv Path:

  • 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

NOTE:

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

It needs location of pipenv package.

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)**

Windows 10

I didn't have to place pipenvPath variable to suppress the annoying message of pipenv not existing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment