創(chuàng)新互聯(lián)www.cdcxhl.cn八線動態(tài)BGP香港云服務(wù)器提供商,新人活動買多久送多久,劃算不套路!
成都創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比開化網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式開化網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋開化地區(qū)。費用合理售后完善,十多年實體公司更值得信賴。這篇文章將為大家詳細(xì)講解有關(guān)python建立venv虛擬環(huán)境的方法,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
創(chuàng)建虛擬環(huán)境在當(dāng)前目錄創(chuàng)建虛擬環(huán)境:
$ python -m venv .1
下面是”venv”的詳細(xì)使用參數(shù):
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標(biāo)準(zhǔn)平臺下:
$ source/bin/activate
在Windows cmd下:
C:>/Scripts/activate.bat
在Windows PowerShell下:
PS C:>測試虛擬環(huán)境/Scripts/Activate.ps1
激活虛擬環(huán)境后,在命令行會提示當(dāng)前虛擬環(huán)境的名稱,就表示激活成功了。
在當(dāng)前虛擬環(huán)境中安裝numpy:
$ pip install numpy
當(dāng)前安裝的numpy包與系統(tǒng)中的不會沖突,下面進(jìn)行測試:
$ python >>> import numpy >>> print(numpy)
如果輸出了numpy的包路徑就表示一切正常。