python多版本工具miniconda的配置優(yōu)化實(shí)現(xiàn)
conda比較重,所以我用了miniconda,切換python版本也足夠方便。
安裝miniconda的步驟請(qǐng)自行搜索。
1.添加path環(huán)境變量
如下三個(gè)路徑添加到path環(huán)境中,前綴按實(shí)際情況修改
miniconda安裝目錄 miniconda安裝目錄\Scripts miniconda安裝目錄\bin
2.修改為國內(nèi)源
家目錄創(chuàng)建C:\Users\用戶名\.condarc文件,內(nèi)容如下:
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 show_channel_urls: true ssl_verify: false
3.常用命令
conda activate 環(huán)境 #切換到對(duì)應(yīng)的環(huán)境 conda env list #列出有哪些環(huán)境 conda remove -n 環(huán)境 --all #刪除一個(gè)環(huán)境 conda create -n 環(huán)境名 python=3.8 #創(chuàng)建新的環(huán)境,并指定python版本 conda init powershell #安裝完初始化的命令
問題點(diǎn):
現(xiàn)在這樣確實(shí)可以用了,但是會(huì)發(fā)現(xiàn)啟動(dòng)powershell會(huì)變的很慢,原因就是conda啟動(dòng)的很慢。
這里介紹一下關(guān)閉的方法。
在C:\Users\用戶名\Documents\WindowsPowerShell文件夾下有,profile.ps1文件,把這個(gè)文件剪切到其它地方。
文件內(nèi)容,參考如下:
profile.ps1
#region conda initialize
# !! Contents within this block are managed by 'conda init' !!
If (Test-Path "miniconda安裝目錄\Scripts\conda.exe") {
(& "miniconda安裝目錄\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | ?{$_} | Invoke-Expression
}
#endregion
此時(shí)powershell的終端已經(jīng)不顯示用的conda的那個(gè)環(huán)境(效果如下),但是啟動(dòng)速度超快。
PS C:\Users\young>
想要用conda時(shí)要怎么辦呢?
1.打開默認(rèn)的profile文件
notepad $PROFILE
說明: powershell中輸入這個(gè)命令,會(huì)打印出profile文件的位置
$PROFILE
2.在文件里新建一個(gè)函數(shù)pp,當(dāng)需要conda時(shí),powershell輸入pp等待加載一兩秒即可。函數(shù)內(nèi)容如下,函數(shù)體的內(nèi)容就是上面profile.ps1的內(nèi)容
function pp{
If (Test-Path "miniconda安裝目錄\Scripts\conda.exe") {
(& "miniconda安裝目錄\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | ?{$_} | Invoke-Expression
}
}
3.演示效果
PS C:\Users\young> pp (base) PS C:\Users\young>
到此這篇關(guān)于python多版本工具miniconda的配置優(yōu)化實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)python miniconda配置優(yōu)化內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
python3 實(shí)現(xiàn)的人人影視網(wǎng)站自動(dòng)簽到
這里給大家分享的是使用Python3結(jié)合計(jì)劃任務(wù),實(shí)現(xiàn)的人人影視網(wǎng)站自動(dòng)簽到功能的代碼,非常的實(shí)用,有需要的小伙伴可以參考下2016-06-06
python GUI庫圖形界面開發(fā)之PyQt5信號(hào)與槽基礎(chǔ)使用方法與實(shí)例
這篇文章主要介紹了python GUI庫圖形界面開發(fā)之PyQt5信號(hào)與槽基礎(chǔ)使用方法與實(shí)例,需要的朋友可以參考下2020-03-03
Python requirements.txt使用小結(jié)
requirements.txt是Python項(xiàng)目中用于記錄項(xiàng)目依賴包及其版本信息的文本文件,類似于Node.js的或Java的pom.xml,下面就來詳細(xì)的介紹一下requirements.txt使用,感興趣的可以了解一下2025-11-11
使用 Python 和 LabelMe 實(shí)現(xiàn)圖片驗(yàn)證碼的自動(dòng)標(biāo)注功能
文章介紹了如何使用Python和LabelMe自動(dòng)標(biāo)注圖片驗(yàn)證碼,主要步驟包括圖像預(yù)處理、OCR識(shí)別和生成標(biāo)注文件,通過結(jié)合PaddleOCR,可以快速實(shí)現(xiàn)驗(yàn)證碼字符的自動(dòng)標(biāo)注,大幅提升工作效率,感興趣的朋友一起看看吧2024-12-12
用Python實(shí)現(xiàn)一個(gè)簡單的用戶系統(tǒng)
大家好,本篇文章主要講的是用Python實(shí)現(xiàn)一個(gè)簡單的用戶系統(tǒng),感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下2022-01-01

