4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

venvのpython仮想環境をgitで共有する

Last updated at Posted at 2022-06-18

ポイント

  • venv環境の共有はrequirments.txtを使う
    • これでライブラリの共有ができる
    • 各自構築したvenv環境内で共有されたライブラリをpipする
  • curl -o .gitignoreでインストールしてきたファイルの名前を指定する
    • 名前を指定せずにインストールするとgitが.gitignoreファイルを認識してくれない
      • .gitignoreというファイル名でないと、gitが認識してくれない
terminal
mkdir test
cd test
mkdir a.git
cd a.git
git init --bare
cd ..
git clone a.git
cd a
curl -o .gitignore https://raw.githubusercontent.com/github/gitignore/main/Global/VirtualEnv.gitignore

python3 -m venv .venv
source .venv/bin/activate
pip install pip-autoremove matplotlib
pip freeze > requirements.txt
deactivate
git add -A 
git commit -m "initial commit"
git push

cd ..
mkdir b
cd b
git clone ../a.git
cd a

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
deactivate
cd ../../../

参考サイト

  1. https://akogare-se.hatenablog.com/entry/2019/01/02/220330
  2. https://www.lisz-works.com/entry/git-venv
4
5
0

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
4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?