为了加快启动项目的速度,我创建了一个小的bash脚本,该脚本执行以下操作:
#!/bin/bash
if [ "$1" == "k3" ]; then
project_path="tau-code/k3-analysis/"
fi
codepath="/media/peter/somedrive/code"
full_path="$codepath/$project_path"
# Go to directory of project
cd $full_path
# Start environment & notebook if available
pipenv shell
jupyter notebook --ip=0.0.0.0
它可以激活环境,但是不运行jupyter
命令。退出环境时,我看到错误:
line 16: jupyter: command not found
我可以在新创建的环境中手动输入jupyter notebook --ip=0.0.0.0
,这确实有效。
可能是什么问题?
答案 0 :(得分:4)
pipenv shell
启动一个新的shell,必须使用exit
将其禁用。在脚本中,调用pipenv shell
之后的任何命令都不会在该新Shell中执行。相反,它们在关闭虚拟环境外壳程序后在同一bash shell中执行。您应该使用pipenv run jupyter notebook --ip=0.0.0.0
shell
将在激活virtualenv的情况下生成一个shell。可以使用exit
停用此shell。run
将通过virtualenv运行给定命令,并转发任何参数(例如$ pipenv run python
或$ pipenv run pip freeze
)。
答案 1 :(得分:1)
您好,您需要添加
pipenv run jupyter notebook