pipenv - 在 macOS 上“pipenv shell”=> bash:update_terminal_cwd:找不到命令
问题描述
试图让 pipenv 在 macOS 10.14.4 上工作。
$cat Pipfile
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
numpy = "==1.14.1"
[requires]
python_version = "3.6.8"
这有效:
$pipenv --rm
Removing virtualenv (/Users/me/.local/share/virtualenvs/blah-zeMrhw5d)…
这有效:
$pipenv install
Creating a virtualenv for this project…
Pipfile: /Users/me/mypath/Pipfile
Using /Users/me/.pyenv/versions/3.6.8/bin/python3 (3.6.8) to create virtualenv…
⠏ Creating virtual environment...Using base prefix '/Users/me/.pyenv/versions/3.6.8'
New python executable in /Users/me/.local/share/virtualenvs/blah-zeMrhw5d/bin/python3
Also creating executable in /Users/me/.local/share/virtualenvs/blah-zeMrhw5d/bin/python
Installing setuptools, pip, wheel...
done.
Running virtualenv with interpreter /Users/me/.pyenv/versions/3.6.8/bin/python3
✔ Successfully created virtual environment!
Virtualenv location: /Users/me/.local/share/virtualenvs/blah-zeMrhw5d
Pipfile.lock (7fd81f) out of date, updating to (89a067)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✔ Success!
Updated Pipfile.lock (7fd81f)!
Installing dependencies from Pipfile.lock (7fd81f)…
▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 1/1 — 00:00:02
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
这不起作用:
$pipenv shell
Launching subshell in virtual environment…
. /Users/alexryan/.local/share/virtualenvs/cabin_monitoring-zeMrhw5d/bin/activate
bash: update_terminal_cwd: command not found
$ . /Users/alexryan/.local/share/virtualenvs/cabin_monitoring-zeMrhw5d/bin/activate
bash: update_terminal_cwd: command not found
(cabin_monitoring) $
每次我在此环境中发出命令时都会引发这些错误。
(blah) >ls -lF
total 12
-rw-r--r-- 1 alexryan staff 159 Apr 30 14:49 Pipfile
-rw-r--r-- 1 alexryan staff 2683 Apr 30 14:50 Pipfile.lock
...
bash: update_terminal_cwd: command not found
(blah) $
(cabin_monitoring) >
来自https://apple.stackexchange.com/a/139808/91429我看到update_terminal_cwd
已定义/etc/bashrc
我可以source /etc/bashrc
让这个错误消失,但这样做会打乱我的提示,因此我在虚拟环境中不再明显。
(blah) $source /etc/bashrc
hostname:blah me$
确保pipenv shell
在 macos 上正常工作的最佳方法是什么?
更新
我正在使用 pyenv 来指定我希望使用的 python 版本,因为 pipenv 似乎需要这个。
我通过安装 pyenvcurl https://pyenv.run | bash
并按要求添加了这些行~/.bashrc
:
# Load pyenv automatically by adding
# the following to ~/.bashrc:
export PATH="/Users/me/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
并确保它~/.bashrc
是这样调用的~/.bash_profile
(因为显然pipenv shell
是一个非登录外壳)。
[[ -f ~/.bashrc ]] && source ~/.bashrc
pyenv 在安装了多个版本的 python 时工作正常。
解决方案
推荐阅读
- ssl - 如何使浏览器信任本地网络 wss:// 连接?
- ubuntu - 是否可以在快照应用程序上运行 cpulimit?
- paypal - 如何在 node.js 中的 paypal 中创建可变的定期付款
- excel - vba excel用变量查找
- rust - 如何获取函数的返回地址?
- javascript - 表格内的复选框并使用 lodash 获取或删除 id
- python - 使用 BS4 进行网页抓取 - “传递值的长度为 0,索引意味着 7”
- regex - 如何使用 sed 删除匹配的行
- jestjs - 笑话:如何测试调度 API 操作的组件
- python-3.x - 使用 pyspark 使用附加条件跟踪前一行值