Django將項(xiàng)目移動(dòng)到新環(huán)境的操作步驟
一、操作步驟
步驟一:輸出虛擬環(huán)境中已安裝包的名稱(chēng)及版本號(hào)并記錄到 requirements.txt 文件中
pip freeze > requirements.txt
步驟二:復(fù)制工程到新環(huán)境,并在項(xiàng)目工程目錄(虛擬環(huán)境)下,打開(kāi)cmd窗口
步驟三:將安裝包保存到文件夾packages里
pip download -r requirements.txt -d packages
步驟四:創(chuàng)建虛擬環(huán)境
python -m venv ./venv
步驟五:將文件導(dǎo)入到虛擬環(huán)境中
步驟六:pycharm打開(kāi)項(xiàng)目工程,并在虛擬環(huán)境下執(zhí)行安裝包
cd venv
pip install --no-index --find-links=packages -r requirements.txt
二、錯(cuò)誤處理
1、報(bào)錯(cuò)如下:
ERROR: Command errored out with exit status 1:
ERROR: Command errored out with exit status 1:
command: 'e:\dev04\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-nffom503\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\
Administrator\\AppData\\Local\\Temp\\pip-install-nffom503\\mysqlclient\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'
"'exec'"'"'))' install --record 'C:\Users\Administrator\AppData\Local\Temp\pip-record-7nnhq8ry\install-record.txt' --single-version-externally-managed --compile --install-headers 'e:\dev04\venv\include\site\python3.9\mysqlclient'
cwd: C:\Users\Administrator\AppData\Local\Temp\pip-install-nffom503\mysqlclient\
Complete output (23 lines):
處理方式:手動(dòng)安裝報(bào)錯(cuò)模塊,此時(shí)該模塊的版本也會(huì)以“最新且適配的方式”安裝成功,出現(xiàn)該問(wèn)題的原因是模塊與現(xiàn)有的python環(huán)境不適配。想要徹底解決,就要使得現(xiàn)在虛擬環(huán)境的版本與原先的python版本保持一致。
pip install mysqlclient
到此這篇關(guān)于Django將項(xiàng)目移動(dòng)到新環(huán)境的操作步驟的文章就介紹到這了,更多相關(guān)Django項(xiàng)目移動(dòng)到新環(huán)境內(nèi)容請(qǐng)搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!
版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。