新聞中心
1、使用前提

海鹽網(wǎng)站制作公司哪家好,找成都創(chuàng)新互聯(lián)!從網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、響應(yīng)式網(wǎng)站建設(shè)等網(wǎng)站項(xiàng)目制作,到程序開發(fā),運(yùn)營維護(hù)。成都創(chuàng)新互聯(lián)從2013年開始到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選成都創(chuàng)新互聯(lián)。
前提:假設(shè)我們在用戶目錄 ~ 下有一個(gè)項(xiàng)目叫 my_project/
我們首先進(jìn)入項(xiàng)目目錄:
cd ~/my_project
進(jìn)入項(xiàng)目后,如果直接執(zhí)行pipenvvinstall,pipen會根據(jù)系統(tǒng)默認(rèn)的python版本創(chuàng)建一個(gè)虛擬環(huán)境。(前提是這個(gè)項(xiàng)目中不存在現(xiàn)有的Pipfile,如果存在,它會根據(jù)Pipfile安裝Pipfile中記錄的相應(yīng)版本和依賴庫)。
但是我們在創(chuàng)建虛擬環(huán)境時(shí)通常會指定python版本,這需要匹配兩三個(gè)參數(shù):
-two使用python2創(chuàng)建虛擬環(huán)境。
-three使用python3創(chuàng)建虛擬環(huán)境。
pipenv install --three # 需要確保系統(tǒng)中存在python3版本
2、實(shí)例
下面是執(zhí)行后的輸出信息:
Creating a virtualenv for this project… Using /usr/local/bin/python3 to create virtualenv… # 這里可以看到繼承自哪個(gè)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學(xué)習(xí)網(wǎng)。
網(wǎng)站欄目:創(chuàng)新互聯(lián)Python教程:python中pipenv的使用
路徑分享:http://m.fisionsoft.com.cn/article/cdpjhds.html


咨詢
建站咨詢
