新聞中心
這里有您想知道的互聯(lián)網營銷解決方案
python建立venv虛擬環(huán)境的方法
這篇文章將為大家詳細講解有關python建立venv虛擬環(huán)境的方法,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
站在用戶的角度思考問題,與客戶深入溝通,找到濱江網站設計與濱江網站推廣的解決方案,憑借多年的經驗,讓設計與互聯(lián)網技術結合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:網站設計制作、成都網站設計、企業(yè)官網、英文網站、手機端網站、網站推廣、申請域名、網絡空間、企業(yè)郵箱。業(yè)務覆蓋濱江地區(qū)。
創(chuàng)建虛擬環(huán)境
在當前目錄創(chuàng)建虛擬環(huán)境:
$ python -m venv .1
下面是”venv”的詳細使用參數:
usage: venv [-h] [--system-site-packages] [--symlinks] [--clear] [--upgrade] [--without-pip] ENV_DIR [ENV_DIR ...] Creates virtual Python environments in one or more target directories. positional arguments: ENV_DIR A directory to create the environment in. optional arguments: -h, --help show this help message and exit --system-site-packages Give access to the global site-packages dir to the virtual environment. --symlinks Try to use symlinks rather than copies, when symlinks are not the default for the platform. --copies Try to use copies rather than symlinks, even when symlinks are the default for the platform. --clear Delete the environment directory if it already exists. If not specified and the directory exists, an error is raised. --upgrade Upgrade the environment directory to use this version of Python, assuming Python has been upgraded in-place. --without-pip Skips installing or upgrading pip in the virtual environment (pip is bootstrapped by default)
激活虛擬環(huán)境
在Posix標準平臺下:
$ source/bin/activate
在Windows cmd下:
C:>/Scripts/activate.bat
在Windows PowerShell下:
PS C:>/Scripts/Activate.ps1
測試虛擬環(huán)境
激活虛擬環(huán)境后,在命令行會提示當前虛擬環(huán)境的名稱,就表示激活成功了。
在當前虛擬環(huán)境中安裝numpy:
$ pip install numpy
當前安裝的numpy包與系統(tǒng)中的不會沖突,下面進行測試:
$ python >>> import numpy >>> print(numpy)
如果輸出了numpy的包路徑就表示一切正常。
關于python建立venv虛擬環(huán)境的方法就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
新聞名稱:python建立venv虛擬環(huán)境的方法
本文網址:http://fisionsoft.com.cn/article/jhojcs.html