新聞中心
1、使用前提

海鹽網(wǎng)站制作公司哪家好,找成都創(chuàng)新互聯(lián)!從網(wǎng)頁設計、網(wǎng)站建設、微信開發(fā)、APP開發(fā)、響應式網(wǎng)站建設等網(wǎng)站項目制作,到程序開發(fā),運營維護。成都創(chuàng)新互聯(lián)從2013年開始到現(xiàn)在10年的時間,我們擁有了豐富的建站經驗和運維經驗,來保證我們的工作的順利進行。專注于網(wǎng)站建設就選成都創(chuàng)新互聯(lián)。
前提:假設我們在用戶目錄 ~ 下有一個項目叫 my_project/
我們首先進入項目目錄:
cd ~/my_project
進入項目后,如果直接執(zhí)行pipenvvinstall,pipen會根據(jù)系統(tǒng)默認的python版本創(chuàng)建一個虛擬環(huán)境。(前提是這個項目中不存在現(xiàn)有的Pipfile,如果存在,它會根據(jù)Pipfile安裝Pipfile中記錄的相應版本和依賴庫)。
但是我們在創(chuàng)建虛擬環(huán)境時通常會指定python版本,這需要匹配兩三個參數(shù):
-two使用python2創(chuàng)建虛擬環(huán)境。
-three使用python3創(chuàng)建虛擬環(huán)境。
pipenv install --three # 需要確保系統(tǒng)中存在python3版本
2、實例
下面是執(zhí)行后的輸出信息:
Creating a virtualenv for this project… Using /usr/local/bin/python3 to create virtualenv… # 這里可以看到繼承自哪個python版本 ?Running virtualenv with interpreter /usr/local/bin/python3 Using base prefix '/usr/local' New python executable in /root/.local/share/virtualenvs/my_project-dhpIKgdN/bin/python3 Also creating executable in /root/.local/share/virtualenvs/my_project-dhpIKgdN/bin/python Installing setuptools, pip, wheel...done. # 這里可以看到虛擬環(huán)境安裝的位置 Virtualenv location: /root/.local/share/virtualenvs/my_project-dhpIKgdN Creating a Pipfile for this project… Pipfile.lock not found, creating… Locking [dev-packages] dependencies… Locking [packages] dependencies… Updated Pipfile.lock (625834)! Installing dependencies from Pipfile.lock (625834)… ? ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00 To activate this project's virtualenv, run the following: $ pipenv shell # 要激活該虛擬環(huán)境,執(zhí)行這條指令
以上就是python中pipenv的使用,希望能對大家有所幫助,更多知識盡在python學習網(wǎng)。
文章標題:創(chuàng)新互聯(lián)Python教程:python中pipenv的使用
網(wǎng)站地址:http://m.5511xx.com/article/cdpjhds.html


咨詢
建站咨詢
