LoginSignup
0
1

Juliaをインストールする(ただし、Jupyter Notebookを使わずに:VSCode, Win/Mac/Linux共通)

Posted at

MATLABユーザーがJuliaをインストールする。

背景

MATLABが遅い。Pythonは嫌い。
→Juliaという言語がいいらしい。

MATLABみたいに、統合した環境でやりたい。Jupyter Notebookみたいなブラウザベースのは好きじゃない。できれば、vscodeでやりたい。

インストール

Windows:

Wingetがインストールされていることを前提とする。
powershellから以下を実行

powershell.ps1
> winget install JuliaLang.Julia
> ls ~\AppData\Local\Programs\Julia-*\bin\julia.exe" | select Directory

で表示されたディレクトリを、コピーしておく。PATHに追加する。

powershell.ps1
> sysdm.cpl

「ユーザー環境変数」の「PATH」に、「新規」で先ほどのディレクトリ(C:\****)を貼り付ける。
powershellを再起動する。

Mac:

Homebrewがインストールされていることを前提とする。されてなければ、先にターミナルから

terminal.sh
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

を先に実行しておくこと。その後、

terminal.sh
$ brew install julia

Linux:

Fedoraの例。各パッケージマネージャーの構文にあわせる。

terminal.bash
$ sudo dnf install julia

以降、OSにかかわらず共通。

Juliaの起動

ターミナルから起動してみる。

Mac-Studio:~ user$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.3 (2024-04-30)
 _/ |\__'_|_|_|\__'_|  |  Built by Homebrew (v1.10.3)
|__/                   |

julia> exit()

VSCodeプラグインの追加

VSCodeは先にインストールしておくこと。公式から落とせばいい

左ツールバーの拡張機能(□4個のボタン)から、「Julia」と検索してインストールする
image.png

動作テスト

適当なフォルダをcodeで開く

terminal.sh
mkdir ~/Documents/juliatest
cd ~/Documents/juliatest
code .

test.jlを左から作成して、例えば、以下のようにして右上の再生ボタン(実行)
image.png

怒られる。

output.log
~~~
ERROR: ArgumentError: Package Plots not found in current path.
- Run `import Pkg; Pkg.add("Plots")` to install the Plots package.
Stacktrace:
 ~~~

パッケージPlotsをインストールしてみる。ここに詳しい
https://qiita.com/skiing_LAL10/items/0c0132a34629fbc8a91f

下のターミナル.jl
julia > ]
(@v1.10) pkg> add Plots
~~~
(@v1.10) pkg> (デリートキー)
julia >

もう一度実行してみる
image.png

0
1
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1