Open6
rye触ってみる
ryeインストールする
curl -sSf https://rye-up.com/get | bash
echo 'source "$HOME/.rye/env"' >> ~/.zshrc
source ~/.zshrc
バージョン確認
$ rye --version
rye 0.3.0
commit: 0.3.0 (85fc3f6a9 2023-05-27)
platform: macos (aarch64)
self-python: cpython@3.10
symlink support: true
参考資料
ryeで空プロジェクト作成
rye init hello-rye
cd hello-rye
python 3.11でpin
rye pin 3.11
python起動することを確認
$ rye run python
Python 3.11.3 (main, May 7 2023, 17:39:14) [Clang 16.0.3 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
main.py作ってみる
vim src/hello_rye/main.py
- ファイル:
src/hello_rye/main.py
def main():
print("Hello, rye!")
if __name__ == "__main__":
main()
main.py叩いてみる
$ rye run python src/hello_rye/main.py
Hello, rye!
pandasいれてみる
rye add pandas
動作確認(※これだと動かないよ)
$ rye run python
Python 3.11.3 (main, May 7 2023, 17:39:14) [Clang 16.0.3 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pandas'
syncが必要
rye sync
再度動作確認
$ rye run python
Python 3.11.3 (main, May 7 2023, 17:39:14) [Clang 16.0.3 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> pd.DataFrame([1,2,3])
0
0 1
1 2
2 3
jupyterいれてみる
rye add --dev jupyterlab
rye sync
起動してみる
rye run jupyter-lab
起動した