Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
201 views
in Technique[技术] by (71.8m points)

macos - Activating virtualenv and opening Jupyter notebooks from a single terminal command

I'd like to be able to open my projects easily using one command in terminal instead of doing what I normally do. I tried creating a command like this in my .zshrc:

my_project() {
    cd my_folder
    source venv/bin/activate
    jupyter notebook
}

Normally if I enter these commands one at a time it opens fine. But I'd rather just run my command and it do everything for me and automatically launch the notebook. When I run this however, it just goes into the folder and stops without running the rest of the commands after it. How do I make it run them one after another?

question from:https://stackoverflow.com/questions/65851982/activating-virtualenv-and-opening-jupyter-notebooks-from-a-single-terminal-comma

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Figured it out! You can run commands after one another by using a semicolon (;). For example using the above code:

my_project() {
cd my_folder;
source venv/bin/activate;
jupyter notebook;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...