一、什么是虛擬環(huán)境
1. 什么是Python環(huán)境
要搞清楚什么是虛擬環(huán)境,首先要清楚Python的環(huán)境指的是什么。當我們在執(zhí)行python test.py時,思考如下問題:
- python哪里來?這個主要歸功于配置的系統(tǒng)環(huán)境變量
PATH
,當我們在命令行中運行程序時,系統(tǒng)會根據(jù)PATH
配置的路徑列表依次查尋是否有可執(zhí)行文件python(在windows中,省略了后綴.exe
),當查尋到該文件時,執(zhí)行該文件; 如果在所有路徑列表中都查找不到,就會報報錯:'python' 不是內(nèi)部或外部命令,也不是可運行的程序或批處理文件。
- test.py代碼中import的模塊在哪里找?import的模塊包含兩類,一類稱為標準庫,隨著python的安裝而安裝;另一類稱為第三方庫,使用
pip
工具或者自己手動安裝的包。模塊的搜索路徑可通過sys.path
查看,主要由可執(zhí)行文件python所在的位置所決定。
Python環(huán)境主要包括以下內(nèi)容:
- 解釋器
python.exe
- Lib目錄
- 標準庫
- site-pakages目錄,默認安裝第三方庫所在的目錄
- Scripts目錄,包含一些執(zhí)行文件
- 包安裝管理工具pip.exe
- 打包工具pyinstaller.exe(需要自己安裝)
- …
- 其他
- 主要包括python解釋器運行時需要的相關(guān)依賴文件,文檔說明等
Python環(huán)境主要由運行python解釋器的位置所決定
2. 什么是虛擬環(huán)境
理解了什么是python環(huán)境,思考下為什么有虛擬環(huán)境的說法。思考以下問題:
- 有兩個項目A和B,如果A和B都要用到某一模塊,但版本不相同怎么辦?
- 在使用pip安裝包時,會發(fā)現(xiàn)在安裝的時候會安裝其它的依賴包,但當我們用pip移除一個包時,卻只移除了指定的包
為了解決上面的問題,python使用了虛擬環(huán)境這個概念,你可以認為是python環(huán)境的多個副本,只是在不同的副本中安裝了不同的包。既然叫虛擬環(huán)境,總得有點不一樣:虛擬環(huán)境中一般不包含標準庫;不包含python解釋器運行時所需的依賴文件;可執(zhí)行文件全部放于Scripts目錄等。
3. 常用工具
知道了什么是虛擬環(huán)境,就應該清楚如何去管理虛擬環(huán)境,這就離不開虛擬環(huán)境管理工具,下面列出了一些常用的工具,并在稍后的內(nèi)容中對部分工具的使用作簡單的介紹。
-
Virtualenv
virtualenv 是非常流行的 python 虛擬環(huán)境配置工具。它不僅同時支持 python2 和 python3,而且可以為每個虛擬環(huán)境指定 python 解釋器,并選擇不繼承基礎(chǔ)版本的包。 -
venv
考慮到虛擬環(huán)境的重要性,Python 從3.3 版本開始,自帶了一個虛擬環(huán)境模塊 venv,關(guān)于該模塊的詳細介紹,可參考 PEP-405 。它的很多操作都和 virtualenv 類似。如果你使用的是python3.3之前版本或者是python2,則不能使用該功能,依賴需要利用virtualenv進行虛擬環(huán)境管理。 -
pipenv
pipenv 是Kenneth Reitz(requests的作者)大神的作品。它結(jié)合了 Pipfile,pip,和virtualenv,能夠有效管理Python多個環(huán)境,各種包。并且windows視為一等公民。-
Pipfile是社區(qū)擬定的依賴管理文件,用于替代過于簡陋的 requirements.txt 文件。Pipfile 文件是 TOML 格式而不是 requirements.txt 這樣的純文本。
-
virtualenv能夠很好的完成虛擬環(huán)境的搭建和python版本的管理,但是跨平臺的使用不太一致,且有時候處理包之間的依賴總存在問題
-
pip能夠很好的完成包的管理,但是仍然推薦pipenv,相當于virtualenv和pip的合體,且更加強大。
-
-
conda
支持Python、R、Java、JavaScript、C等多種開發(fā)語言的包、依賴和環(huán)境管理工具,能運行在Windows、MacOS、Linux多個平臺,可以在本地輕松創(chuàng)建、保存、切換環(huán)境。當安裝anaconda時,會自動安裝conda工具。 -
Python Launcher for Windows
Python 從3.3版本開始,在 Windows 系統(tǒng)中自帶了一個py.exe
啟動工具。如果你是使用 Python.org 官網(wǎng)下載的安裝包安裝的 Python 3.3(或更新版本)環(huán)境,那么可以直接在命令提示符中使用這個工具(在windows中,py.exe
會安裝在C:\Windows
目錄)。
py 可以打開默認的 python 提示符;py -2.7
和py -3
打開對應的 Python 版本,py -0
將列出系統(tǒng)中安裝了哪些版本的python
二、pipenv
pipenv創(chuàng)建虛擬環(huán)境后,會在工程目錄生成如下兩個文件:
- Pipfile:用于保存項目的python版本、依賴包等相關(guān)信息。該文件可以單獨移放到其他項目內(nèi),用于項目虛擬環(huán)境的建立和依賴包的安裝
- Pipfile.lock:用于對Pipfile的鎖定
1. 安裝pipenv
pip install pipenv -i https://pypi.tuna.tsinghua.edu.cn/simple
-i選項指定庫的安裝源,安裝源要滿足PEP 503的描述,國內(nèi)常用的源:
- 清華大學:https://pypi.tuna.tsinghua.edu.cn/simple
- 中國科學技術(shù)大學 : https://pypi.mirrors.ustc.edu.cn/simple
- 豆瓣:http://pypi.douban.com/simple/
- 阿里:https://mirrors.aliyun.com/pypi/simple/
2. 命令概覽
學習使用工具/命令的萬能大法 – 查看幫助信息。
pipenv -h
Usage: pipenv [OPTIONS] COMMAND [ARGS]...
Options:
--where Output project home information.
--venv Output virtualenv information.
--py Output Python interpreter information.
--envs Output Environment Variable options.
--rm Remove the virtualenv.
--bare Minimal output.
--man Display manpage.
--support Output diagnostic information for use in
GitHub issues.
--site-packages / --no-site-packages
Enable site-packages for the virtualenv.
[env var: PIPENV_SITE_PACKAGES]
--python TEXT Specify which version of Python virtualenv
should use.
--three / --two Use Python 3/2 when creating virtualenv.
--clear Clears caches (pipenv, pip). [env var:
PIPENV_CLEAR]
-v, --verbose Verbose mode.
--pypi-mirror TEXT Specify a PyPI mirror.
--version Show the version and exit.
-h, --help Show this message and exit.
Usage Examples:
Create a new project using Python 3.7, specifically:
$ pipenv --python 3.7
Remove project virtualenv (inferred from current directory):
$ pipenv --rm
Install all dependencies for a project (including dev):
$ pipenv install --dev
Create a lockfile containing pre-releases:
$ pipenv lock --pre
Show a graph of your installed dependencies:
$ pipenv graph
Check your installed dependencies for security vulnerabilities:
$ pipenv check
Install a local setup.py into your virtual environment/Pipfile:
$ pipenv install -e .
Use a lower-level pip command:
$ pipenv run pip freeze
Commands:
check Checks for PyUp Safety security vulnerabilities and against PEP
508 markers provided in Pipfile.
clean Uninstalls all packages not specified in Pipfile.lock.
graph Displays currently-installed dependency graph information.
install Installs provided packages and adds them to Pipfile, or (if no
packages are given), installs all packages from Pipfile.
lock Generates Pipfile.lock.
open View a given module in your editor.
run Spawns a command installed into the virtualenv.
scripts Lists scripts in current environment config.
shell Spawns a shell within the virtualenv.
sync Installs all packages specified in Pipfile.lock.
uninstall Uninstalls a provided package and removes it from Pipfile.
update Runs lock, then sync.
3. pipenv基本使用
1)創(chuàng)建虛擬環(huán)境
創(chuàng)建工程目錄,并進入工程目錄
mkdir test
cd test
創(chuàng)建虛擬環(huán)境
pipenv install `--python 3.8`
如果在該工程不錄中沒有Pipfile文件,則會自動創(chuàng)建Pipfile和Pipfile.lock兩個文件;如果該工程目錄中有Pipfile,將安裝Pipfile列出的相應依賴包,安裝完成后生成Pipfile.lock
可以使用如下參數(shù)來定義環(huán)境:
- –python 3.8 將指定該虛擬環(huán)境的python使用3.8的最新版本,有以下兩種情況
- 如果系統(tǒng)已經(jīng)安裝了python3.8,則使用系統(tǒng)已經(jīng)安裝的python3.8版本
- 如果系統(tǒng)中沒有python3.8版本
- 如果已經(jīng)安裝pyenv或者asdf,會提示是否需要使用pyenv或者asdf安裝對應版本的python
- 如果沒有安裝pyenv和asdf,則創(chuàng)建環(huán)境失敗
- 此外,–python后面跟的參數(shù)可以不是版本號,而是安裝的python解釋器的路徑
-
--three
/--two
使用 Python 3或者2創(chuàng)建虛擬環(huán)境
-
--pypi-mirror
指定安裝源 -
--site-packages
/--no-site-packages
是否使用python基礎(chǔ)環(huán)境中的site-packages路徑
查看虛擬環(huán)境相關(guān)信息
#查看工程根目錄信息
pipenv --where
#查看當前虛擬環(huán)境的信息
pipenv --venv
#查看python解釋器的信息
pipenv --py
#查看環(huán)境變量選項
pipenv --envs
觀察虛擬環(huán)境目錄的文件
pyvenv.cfg
home = d:\programdata\anaconda3 implementation = CPython version_info = 3.8.5.final.0 virtualenv = 20.10.0 include-system-site-packages = false base-prefix = d:\programdata\anaconda3 base-exec-prefix = d:\programdata\anaconda3 base-executable = d:\programdata\anaconda3\python.exe prompt = (test)
這是虛擬環(huán)境的配置文件,包含了python環(huán)境的相關(guān)信息。
.project
E:\Projects\test
指定了該虛擬環(huán)境對應的工程目錄
2)激活虛擬環(huán)境
pipenv shell
注意:
在激活虛擬環(huán)境時,如果在windows上使用powershell,可能在命令行的前面不能顯示虛擬環(huán)境的名稱,比如顯示如下信息,但不影響正常使用
進入工程目錄后,如果直接使用上面的命令激活虛擬環(huán)境,而不是使用pipenv install 創(chuàng)建虛擬環(huán)境,這時pipenv會自動創(chuàng)建相應的虛擬環(huán)境。
3)虛擬環(huán)境包的管理
包的安裝
pipenv install -h
Usage: pipenv install [OPTIONS] [PACKAGES]...
Installs provided packages and adds them to Pipfile, or (if no packages are
given), installs all packages from Pipfile.
Options:
--system System pip management. [env var:
PIPENV_SYSTEM]
-c, --code TEXT Install packages automatically discovered
from import statements.
--deploy Abort if the Pipfile.lock is out-of-date, or
Python version is wrong.
--site-packages / --no-site-packages
Enable site-packages for the virtualenv.
[env var: PIPENV_SITE_PACKAGES]
--skip-lock Skip locking mechanisms and use the Pipfile
instead during operation. [env var:
PIPENV_SKIP_LOCK]
-e, --editable TEXT An editable Python package URL or path,
often to a VCS repository.
--ignore-pipfile Ignore Pipfile when installing, using the
Pipfile.lock. [env var:
PIPENV_IGNORE_PIPFILE]
--selective-upgrade Update specified packages.
-r, --requirements TEXT Import a requirements.txt file.
--extra-index-url TEXT URLs to the extra PyPI compatible indexes to
query for package look-ups.
-i, --index TEXT Target PyPI-compatible package index url.
--sequential Install dependencies one-at-a-time, instead
of concurrently. [env var:
PIPENV_SEQUENTIAL]
-d, --dev Install both develop and default packages
[env var: PIPENV_DEV]
--keep-outdated Keep out-dated dependencies from being
updated in Pipfile.lock. [env var:
PIPENV_KEEP_OUTDATED]
--pre Allow pre-releases.
--python TEXT Specify which version of Python virtualenv
should use.
--three / --two Use Python 3/2 when creating virtualenv.
--clear Clears caches (pipenv, pip). [env var:
PIPENV_CLEAR]
-v, --verbose Verbose mode.
--pypi-mirror TEXT Specify a PyPI mirror.
-h, --help Show this message and exit.
常用參數(shù)示例:
#使用清華源安裝numpy包
pipenv install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple
#如果有requirements.txt文件,可以使用下面命令安裝requirements.txt列出的包
pipenv install -r path/to/requirements.txt
#安裝指定版本的numpy
pipenv install numpy~=1.22.3 #等價于 numpy==1.22.3
#注意,包的版本號可以使用~=、==、>=、 <=、 >、 <、 != 等方式來限制
#在pipenv中,提倡使用 ~= 標識符而不是 == 標識符,因為后者會阻止 pipenv 更新包
思考:在虛擬環(huán)境中,使用pip和pipenv都可以安裝包,區(qū)別在哪里?
使用pipenv安裝的包會將相關(guān)信息寫入Pipfile和Pipfile.lock,而使用pip安裝包后,只在虛擬環(huán)境的site-packages目錄安裝了相應包,而不會將信息寫入Pipfile和Pipfile.lock
查看虛擬環(huán)境中安裝的包信息
pipenv graph
包的刪除
pipenv uninstall numpy
注意,如果沒有激活虛擬環(huán)境,即沒有運行pipenv shell,若想使用pip list查看虛擬環(huán)境中所安裝的包時,可以使用pipenv run pip list
4)退出虛擬環(huán)境
exit
5)刪除虛擬環(huán)境
pipenv --rm
當退出虛擬環(huán)境,刪除虛擬環(huán)境后,對應的虛擬環(huán)境目錄會刪除掉,但工程目錄下的Pipfile.lock和Pipfile兩個文件依然存在。
6)其他
如果已經(jīng)刪除了虛擬環(huán)境,可以使用pipenv --python 3.8 install
重新創(chuàng)建虛擬環(huán)境以完成下面的示例。
需要共享項目環(huán)境時,共享Pipfile文件即可
想要在虛擬環(huán)境中執(zhí)行腳本,比如執(zhí)行main.py文件,可以使用命令pipenv run python main.py
可以在Pipfile文件中自定義命令,比如在Pipfile末尾添加如下內(nèi)容,則添加了兩個自定義命令print
和list
,分別打印Hello World!
和列出虛擬環(huán)境中所裝的包:
[scripts]
print = "python -c \"print('Hello World!')\""
list = "pip list"
則可以使用如下方式運行代碼
其他
pipenv lock #生成Pipfile.lock.
pipenv sync #安裝Pipfile.lock文件中指定的所有包
pipenv update #等價于先lock, 后 sync.
4. 虛擬環(huán)境的本質(zhì)
虛擬環(huán)境的本質(zhì)就是修改了sys.path的值,下面分別查看在虛擬環(huán)境和不在虛擬環(huán)境中的sys.path值
在主要的區(qū)別在于第三方包的路徑時,一個用的是虛擬環(huán)境的site-packages,而另一個是使用的python環(huán)境中的site-packages。
三、venv
Python 從3.3 版本開始,自帶了一個虛擬環(huán)境模塊 venv
,關(guān)于該模塊的詳細介紹,可參考PEP-405
和。
1. 命令概覽
查看venv幫助信息:
python -m venv -h
usage: v
env [-h] [--system-site-packages] [--symlinks | --copies] [--clear] [--upgrade] [--without-pip] [--prompt PROMPT] 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 the virtual environment access to the system site-packages dir.
--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 contents of the environment directory if it already exists, before environment creation.
--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)
--prompt PROMPT Provides an alternative prompt prefix for this environment.
Once an environment has been created, you may wish to activate it, e.g. by sourcing an activate script in its bin directory.
2. 創(chuàng)建虛擬環(huán)境
python -m venv venv_demo
這里使用得最多的兩個選項為:
-
--system-site-packages
:是否包含Python系統(tǒng)的site-packages,添加這個選項后,會在sys.path
的末尾添加上系統(tǒng)的site-packages相關(guān)目錄。不添加這個選項時,將不會包含系統(tǒng)的site-packages* -
--without-pip
:虛擬環(huán)境中是否包含pip.exe
3. 虛擬環(huán)境的激活
在虛擬環(huán)境的Scripts目錄中有兩個腳本文本activate.bat
和deactivate.bat
,分別用于激活虛擬環(huán)境和退出虛擬環(huán)境。
注意:
-
在pipenv創(chuàng)建的虛擬環(huán)境中同樣有這兩個腳本文件
-
activate文件有多個版本,當在windows系統(tǒng)時,如果用CMD時,使用activate.bat;如果用PowerShell時使用activate.psl
當我們激活虛擬環(huán)境后,系統(tǒng)的PATH路徑的最前面添加了虛擬環(huán)境的Scripts目錄,該目錄下包含了pip.exe和python.exe??梢缘玫饺缦陆Y(jié)論: -
如果不激活虛擬環(huán)境,直接運行虛擬環(huán)境的Scripts目錄下的python.exe,則此時的交互環(huán)境也將是在此虛擬環(huán)境下
-
如果不激活虛擬環(huán)境,直接運行虛擬環(huán)境的Scripts目錄下的pip.exe進行包的安裝,則安裝的包同樣安裝在虛擬環(huán)境中
注意,這里使用的PowerShell,所以查看path環(huán)境變量時使用的$env:path,如果是CMD,查看環(huán)境變量可以使用echo %PATH%
4. 虛擬環(huán)境包的管理
使用pip工具進行虛擬環(huán)境中包的管理,有兩種方式
- 第一種方式,使用虛擬環(huán)境中的activate激活虛擬環(huán)境
- 第二種方式,不激活虛擬環(huán)境,但是運行的Pip指定為虛擬環(huán)境中Scripts目錄下的pip.exe
pip命令的基本使用將在文末介紹。
四、conda
conda支持Python、R、Java、JavaScript、C等多種開發(fā)語言的包、依賴和環(huán)境管理工具,能運行在Windows、MacOS、Linux多個平臺,可以在本地輕松創(chuàng)建、保存、切換環(huán)境。當安裝anaconda時,會自動安裝conda工具。
conda與pipenv,venv等虛擬環(huán)境管理工具的最大的不同在于:conda虛擬環(huán)境是獨立于操作系統(tǒng)解釋器環(huán)境的,即無論操作系統(tǒng)解釋器什么版本(哪怕2.7),我也可以指定虛擬環(huán)境python版本為3.6,而venv是依賴主環(huán)境的。
1. 創(chuàng)建虛擬環(huán)境
conda create --name py3.6 python=3.6
創(chuàng)建好虛擬環(huán)境后,你會發(fā)現(xiàn)虛擬環(huán)境py3.6的內(nèi)容與一個實體python環(huán)境是一樣的。所以,conda的環(huán)境管理更像是實體環(huán)境的一個拷貝,而不像是一個虛擬環(huán)境
2. 環(huán)境的激活和退出
conda activate py3.6
conda deactivate
3. 包的管理
#安裝numpy模塊
conda install numpy
#查看已安裝的模塊
conda list
#搜索模塊信息
conda search numpy
#刪除模塊
conda remove numpy
#更新模塊
conda update numpy
#更新全部模塊:
conda update --all
#更新conda
conda update conda
#更新python
conda update python
使用conda安裝包往往很慢,需要設(shè)置conda的國內(nèi)源,具體做法如下:
生成.condarc配置文件
conda config --set show_channel_urls yes
修改.condarc
channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/simpleitk - defaults show_channel_urls: true ssl_verify: true
也可以使用如下命令添加源
conda config --add channels ‘https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/’
查看設(shè)置的源
conda --show channels
也可以使用conda info查看基本信息
4. 環(huán)境的刪除
conda remove --name py3.6 --all
5. 查看所有環(huán)境
conda env list
ps1:pip基本使用
查看幫助:
pip -h
Usage:
pip <command> [options]
Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
check Verify installed packages have compatible dependencies.
config Manage local and global configuration.
search Search PyPI for packages.
cache Inspect and manage pip's wheel cache.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
completion A helper command used for command completion.
debug Show information useful for debugging.
help Show help for commands.
General Options:
-h, --help Show help.
--isolated Run pip in an isolated mode, ignoring environment variables and user configuration.
-v, --verbose Give more output. Option is additive, and can be used up to 3 times.
-V, --version Show version and exit.
-q, --quiet Give less output. Option is additive, and can be used up to 3 times (corresponding to
WARNING, ERROR, and CRITICAL logging levels).
--log <path> Path to a verbose appending log.
--no-input Disable prompting for input.
--proxy <proxy> Specify a proxy in the form [user:passwd@]proxy.server:port.
--retries <retries> Maximum number of retries each connection should attempt (default 5 times).
--timeout <sec> Set the socket timeout (default 15 seconds).
--exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup,
(a)bort.
--trusted-host <hostname> Mark this host or host:port pair as trusted, even though it does not have valid or any
HTTPS.
--cert <path> Path to alternate CA bundle.
--client-cert <path> Path to SSL client certificate, a single file containing the private key and the
certificate in PEM format.
--cache-dir <dir> Store the cache data in <dir>.
--no-cache-dir Disable the cache.
--disable-pip-version-check
Don't periodically check PyPI to determine whether a new version of pip is available for
download. Implied with --no-index.
--no-color Suppress colored output
--no-python-version-warning
Silence deprecation warnings for upcoming unsupported Pythons.
--use-feature <feature> Enable new functionality, that may be backward incompatible.
--use-deprecated <feature> Enable deprecated functionality, that will be removed in the future.
1. 安裝
1)安裝requirements.txt文件列出的包
pip install -r requriements.txt
2)安裝指定包
pip install numpy
3)安裝whl文件
pip install wheel
pip install xxxx.whl
常用參數(shù)主要包括:
-i <url> 或者 --index-url <url>:指定安裝源,通常設(shè)為國內(nèi)源會更快
2. 更新
pip install --upgrade 包名稱
如果要指定升級到某個版本,可以使用pip install --upgrade 包名稱==版本號
注意:不要使用pip install --upgrade pip更新pip自身,否則會在更新pip的時候刪除掉pip,然后出現(xiàn)No module named ‘pip’的情況 ,可運行如下命令安裝pip:
python -m ensurepip
如果要更新pip自身,可以使用如下命令:
python -m pip install --upgrade pip
3. 刪除
刪除指定的包
pip uninstall 包名
刪除requriements.txt文件中列出的包
pip uninstall -r requriements.txt
4. 查看
列出安裝的所有包:
pip list
查看某一個包的具體信息
pip show 包名
5. 導出安裝包列表
pip freeze > requirements.txt
導出pip所在環(huán)境中所安裝的所有包,將其輸出到requirements.txt文件中
ps2:如何在pycharm使用虛擬環(huán)境
在創(chuàng)建pycharm工程時,記得指定python解釋器為虛擬環(huán)境中Scripts目錄下的python.exe即可文章來源:http://www.zghlxwxcb.cn/news/detail-716482.html
轉(zhuǎn)載:https://javaforall.cn/175522.html原文鏈接:https://javaforall.cn文章來源地址http://www.zghlxwxcb.cn/news/detail-716482.html
到了這里,關(guān)于Python虛擬環(huán)境(pipenv、venv、conda一網(wǎng)打盡)[通俗易懂]的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!