Home:ALL Converter>command not found: pipenv

command not found: pipenv

Ask Time:2020-05-23T18:19:31         Author:Makoto Miyazaki

Json Formatter

I wanted to create a virtual environment and use VSCode(Ver 1.45.1). But started to have errors after restarting VSCode. Long story short, I cannot locate my pipenv to work with my project. Here I wrote down the steps I took to debug, but still cannot locate what the issue is. Sorry that my description is long but I really need help... Any advice/solution would be appreciated!

First I followed this instruction to setup pipenv.

pip3 install --user pipenv
export PATH="$PATH:/Users/mmiyazaki/Library/Python/3.6/bin"

So far, so good. It worked perfectly and I was indeed working with the virtual environment I made. I was able to install packages using pipenv install command. In the project folder, I have Pipfile which lists up necessary package dependencies for this project.

However, when I closed VSCode and restarted, this error showed up.

Workspace contains Pipfile but 'pipenv' was not found. Make sure 'pipenv' is on the PATH.

I made sure that I have pipenv.

MBP-mmiyazaki:Airline_analysis mmiyazaki$ ls /Users/mmiyazaki/Library/Python/3.6/bin
epylint                   jupyter                         jupyter-nbextension             pipenv
iptest                    jupyter-bundlerextension        jupyter-notebook                pipenv-resolver

So I tried this solution. From the settings UI of VSCode, I changed python.pipenvPath to the absolute path to the pipenv executable(/Users/mmiyazaki/Library/Python/3.6/bin). I tried to change both User and Workspace. However even I restart VSCode the error still persists.

Workspace contains Pipfile but '/Users/mmiyazaki/Library/Python/3.6/bin' was not found. Make sure '/Users/mmiyazaki/Library/Python/3.6/bin' is on the PATH.

So I tried again.

MBP-mmiyazaki:Airline_analysis mmiyazaki$ which pipenv / where pipenv
(this returned nothing)
MBP-mmiyazaki:Airline_analysis mmiyazaki$ pip3 install --user pipenv
(installed without problem)
MBP-mmiyazaki:Airline_analysis mmiyazaki$ pipenv install datetime
zsh: command not found: pipenv
MBP-mmiyazaki:Airline_analysis mmiyazaki$ which pipenv / where pipenv
pipenv not found

I added the path to ~/.zshrc like below but still the error exists.

# export PATH=$HOME/bin:/usr/local/bin:/Users/mmiyazaki/Library/Python/3.6/bin$PATH

By the way,

MBP-mmiyazaki:Airline_analysis mmiyazaki$ cat ~/.bashrc
cat: .bashrc: No such file or directory

MBP-mmiyazaki:Airline_analysis mmiyazaki$ cat ~/.profile
PATH=$PATH:/Users/mmiyazaki/Library/Python/3.6

MBP-mmiyazaki:Airline_analysis mmiyazaki$ cat ~/.bash_profile
# added by Anaconda3 2019.10 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/mmiyazaki/opt/anaconda3/bin/conda' 
shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/Users/mmiyazaki/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/mmiyazaki/opt/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/Users/mmiyazaki/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<

I checked ~/.local because I learned that when you install something using --user it goes there. And I found that there is this sub directory which seems like related to my project.

MBP-mmiyazaki:Airline_analysis mmiyazaki$ ls ~/.local/share/virtualenvs/Airline_analysis--he80DQa
bin        etc        lib        pyvenv.cfg share      src

And I'm stuck here to further investigate what the issue is. Everything I wrote down above was done in iTerm2, and the shell is zsh. In VSCode, the terminal shell is bash. But it gives the same error.

Author:Makoto Miyazaki,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/61970537/command-not-found-pipenv
yy