# Pipenv --- > - 根據參考文章所做整理,日常開發已足夠使用的指令。 > - https://stackoverflow.com/questions/41573587/what-is-the-difference-between-venv-pyvenv-pyenv-virtualenv-virtualenvwrappe/41573588#41573588?hmsr=pycourses.com&utm_source=pycourses.com&utm_medium=pycourses.com > - https://docs.pipenv.org/en/latest/ > - https://medium.com/@chihsuan/pipenv-%E6%9B%B4%E7%B0%A1%E5%96%AE-%E6%9B%B4%E5%BF%AB%E9%80%9F%E7%9A%84-python-%E5%A5%97%E4%BB%B6%E7%AE%A1%E7%90%86%E5%B7%A5%E5%85%B7-135a47e504f4 > - https://segmentfault.com/a/1190000012837890 > - https://codinganimal.info/%E7%94%A8-pipenv-%E4%BE%86%E7%AE%A1%E7%90%86-python-%E9%96%8B%E7%99%BC%E7%92%B0%E5%A2%83-ce9f619825a2 > --- > * pipenv == pip + virutalenv > * pipfile & Pipfile.lock == requirement.txt --- $ pip install pipenv $ pipenv --python 3.x #指定python版本 - 在專案目錄下,新增虛擬環境 $ pipenv install $ pipenv install --three #python3 $ pipenv install --two #python2 - 移除虛擬環境 $ pipenv --rm > * Pipenv 會自動產生一個 Pipfile,用來記錄所安裝的套件。 > * 額外產生 Pipfile.lock來記錄,所需相依套件的版本,這是用來確保在任何地方透過這份檔案安裝套件都是相同的套件 > * 可以用$pipenv graph查看套件互相依賴的關係 - 進入當前虛擬環境 $ pipenv shell $ pipenv shell --three #指定 - 下載套件 $ pipenv install requests $ pipenv uninstall request - 執行 $ pipenv python xx.py > Pipfile預設也區分了 development 與 production 環境。 - 僅限安裝在開發環境(將會出現在[dev-packages]中,若無指定則在[packages]。) $ pipenv install --dev requests --three - 產生requirements.txt $ pipenv lock --requirements > requirements.txt $ pipenv lock --r > requirements.txt $ pipenv lock -r [--dev] > requirements.txt > 在安裝時,指定--dev參數,則只安裝[dev-packages]下的套件,若安裝時不定指定--dev參數, 只會安裝[packages]下的套件。 > [requires]下的python在構建新的虛擬環境時,若沒有會自動下載安裝。 - 透過requirements安裝 $ pipenv install -r requirements.txt - 套件安全檢查 $ pipenv check ###### tags: `python` `pipenv` `pip`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up