Running Linux Commands in Jupyter Notebook

huangapple go评论73阅读模式
英文:

Running Linux Commands in Jupyter Notebook

问题

I have a google colab file that I want to run in Visual Studio Code. Normal cells are running ok but I have the following cell:

1. Downloads, extracts, and sets the permissions for the Elasticsearch installation image:

%%bash

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.9.2-linux-x86_64.tar.gz -q
tar -xzf elasticsearch-7.9.2-linux-x86_64.tar.gz
chown -R daemon:daemon elasticsearch-7.9.2

The problem is that I am getting SyntaxError: invalid syntax on the wget

I have tried multiple solutions from stackoverflow

  1. Use the generic %%bash I use in Google Colab too.
  2. Use %%shell
  3. Use the longer version of 1, %%script bash
  4. Use %%script bash
  5. Use the shortcut %%!

I used source like this, this. This is the tutorial I used

英文:

I have a google colab file that I want to run in Visual Studio Code. Normal cells are running ok but I have the following cell:

# 1. Downloads, extracts, and sets the permissions for the Elasticsearch installation image:
%%bash

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.9.2-linux-x86_64.tar.gz -q
tar -xzf elasticsearch-7.9.2-linux-x86_64.tar.gz
chown -R daemon:daemon elasticsearch-7.9.2

The problem is that I am getting SyntaxError: invalid syntax on the wget

I have tried multiple solutions from stackoverflow

  1. Use the generic %%bash I use in Google Colab too.
  2. Use %%shell
  3. Use the longer version of 1, %%script bash
  4. Use %%script bash
  5. Use the shortcut %%!

I used source like this, this. This is the tutorial I used

答案1

得分: 1

这是正确的语法。

英文:

Ok I found the solution by myself

# 1. Downloads, extracts, and sets the permissions for the Elasticsearch installation image:
%%!

!wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.9.2-linux-x86_64.tar.gz -q
!tar -xzf elasticsearch-7.9.2-linux-x86_64.tar.gz
!chown -R daemon:daemon elasticsearch-7.9.2

This is the correct syntax

huangapple
  • 本文由 发表于 2023年5月18日 01:28:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76274733.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定