Skip to Content
エクセルのためのPython (Japanese Edition), 2nd Edition
book

エクセルのためのPython (Japanese Edition), 2nd Edition

by Felix Zumstein
May 2026
Intermediate
418 pages
6h 42m
Japanese
O'Reilly Media, Inc.
Content preview from エクセルのためのPython (Japanese Edition), 2nd Edition

付録A. uvパッケージマネージャー

第2章では、uv sync を実行するよう指示したが、これにより本書で使用した Python とすべてのパッケージのインストールが完了した。この付録では、uv を使って新しいプロジェクトを作成する方法、および依存関係を追加、除去、アップグレードする方法を説明する。また、プロジェクトディレクトリの外で作業できる--projectオプションについても紹介する。最後に、知っておくべき他のパッケージマネージャーについて簡単に概要を説明する。

前提条件

この付録では、第2章の説明に従ってuvがインストールされていることを前提としている。

新しいプロジェクトの作成

uvを使って新しいプロジェクトを作成するには、ターミナルを開き、プロジェクトフォルダを作成したいディレクトリに移動する。この付録の目的は、プロジェクト名をmyprojectとし、ユーザディレクトリ内に作成することである。

ターミナル(Windows)

cd %USERPROFILE%
uv init --python=3.14 myproject

ターミナル(macOS)

cd ~
uv init --python=3.14 myproject

--python=3.14、使用したい Python のバージョンに置き換えてください。利用可能な Python バージョンのリストは、uv python list を実行することで確認できる。

ローカルフォルダを選択する

uvプロジェクトは、必ず自分のマシンのローカルフォルダに作成するようにしよう。uvはPython環境をプロジェクトフォルダ内にインストールするため、OneDriveやDropboxのようなサービスを使用すると、仮想環境がクラウドにアップロードされ、処理が非常に遅くなってしまうからだ。

次に、myprojectディレクトリに移動し、環境を同期する:

ターミナル(Windows および macOS)

cd myproject
uv sync

これにより、仮想環境(.venvディレクトリ)とuv.lockファイルが作成される。これらについては後ほど詳しく説明する。

VS Codeでプロジェクトを開く前に同期する

VS Codeでプロジェクトを開く前に、ターミナルで`uv sync`を実行すること。これにより、手動操作なしにVS Codeが正しい仮想環境を発見できるようになる。

uv sync を実行した後、VS Code でプロジェクトを開く(コマンドのドットは現在のディレクトリを参照することに注意)。

ターミナル(Windows および macOS)

code .

VS Codeのエクスプローラーには、uvによって生成されたファイルがいくつか表示される:

これが仮想環境を含むフォルダだ。仮想環境とは何かについては、第2章を参照のこと。

これは、バージョン管理システムであるGitによってトラッキングされないファイルのリストを含む(Gitがインストールされている場合にのみ作成される)。

このファイルは、最初のコマンドの--python` オプションに従って Python のバージョンを固定する。必要に応じて、手動でファイルを編集するか、`uv python pin 3.14` を実行して変更できる。

main.py

これは単なるサンプルファイルなので、すぐに `uv run main.py` を実行して、すべてが正常に動作するか確認できる。

pyproject.toml
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

大規模言語モデル:難しい部分 (Japanese Edition)

大規模言語モデル:難しい部分 (Japanese Edition)

Thársis T. P. Souza, Jonathan K. Regenstein

Publisher Resources

ISBN: 0642572395971