Pipenv 安装在 Ubuntu 上,WSL 失败

Pipenv install on Ubuntu and WSL fails

出于某种原因,当我 运行 pipenv install 它试图执行我的 Windows python.exe:

OSError: [Errno 8] Exec format error: '/mnt/c/Users/<MY_USER_NAME>/AppData/Local/
Microsoft/WindowsApps/python.exe'

我是 运行宁 WSL Ubuntu 18.04。我已经使用以下命令安装了 Pipenv:

sudo apt install python3-pip
pip3 install --user pipenv
python3 -m site --user-base

已将 ~/.local/bin 添加到 ~/.profile PATH,然后是 source ~/.profile

这对我有用:

pipenv install --python=/usr/bin/python3.6

解释:https://github.com/pypa/pipenv/issues/3488

The python version on Windows is higher than that on WSL, making it come before the latter one..

Specify python path explicitly can fix the problem:

$ pipenv --python /usr/bin/python3