本篇繼python 深度學(xué)習(xí) 解決遇到的報錯問題7-CSDN博客
目錄
一、OSError: [WinError 127] 找不到指定的程序。 Error loading "D:\my_ruanjian\conda-myenvs\deeplearning\lib\site-packages\torch\lib\caffe2_detectron_ops.dll" or one of its dependencies.
二、proj.db contains DATABASE.LAYOUT.VERSION.MINOR = 0 whereas a number >= 2 is expected. It comes from another PROJ installation
三、?There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: EE certificate key too weak (_ssl.c:1002)'))) - skipping
四、Max retries exceeded with url: /pkgs/main/linux-64/current_repodata.json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: EE certificate key too weak (_ssl.c:1002)')))
五、ImportError: cannot import name 'clock' from 'time' (unknown location)
六、UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x00000200EDD9BEA0>
一、OSError: [WinError 127] 找不到指定的程序。 Error loading "D:\my_ruanjian\conda-myenvs\deeplearning\lib\site-packages\torch\lib\caffe2_detectron_ops.dll" or one of its dependencies.
報錯:
原因:是由于torch
與torchaudio
版本不匹配導(dǎo)致的
解決方法:
二、proj.db contains DATABASE.LAYOUT.VERSION.MINOR = 0 whereas a number >= 2 is expected. It comes from another PROJ installation
場景:最近發(fā)現(xiàn)一個問題,在使用GDAL+Python進(jìn)行開發(fā)時,代碼總報如下錯誤:
原因:從錯誤里可以看出,GDAL在調(diào)用PROJ時,遇到了版本沖突的問題。
- GDAL底層使用PROJ的庫,進(jìn)行坐標(biāo)系相關(guān)的轉(zhuǎn)換;
- PostgreSQL數(shù)據(jù)庫插件PostGIS 也是使用了PROJ;
兩個工具安裝的PROJ庫版本不一樣,且在計算機(jī)環(huán)境變量里相互干擾。
解決方法:找到對應(yīng)自己的python包的安裝地址,
import os
# 對應(yīng)自己的python包的安裝地址
os.environ['PROJ_LIB'] = r'D:\my\python-pycharm\python-envs\pathplanning\Lib\site-packages\pyproj\proj_dir\share\proj'
然后運(yùn)行代碼時,就不報錯誤了。
三、?There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: EE certificate key too weak (_ssl.c:1002)'))) - skipping
報錯:使用pip install 某個包的時候報錯
原因分析:無法訪問到https://pypi.tuna.tsinghua.edu.cn/simple/pip,SSL證書認(rèn)證問題。
解決方法:此時需要獲得?ssl證書的認(rèn)證,需要在原來的安裝命令后增加:-i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com (也可換其他源),這是阿里源?--trusted-host mirrors.aliyun.com 這是為了獲得ssl證書的認(rèn)證。
四、Max retries exceeded with url: /pkgs/main/linux-64/current_repodata.json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: EE certificate key too weak (_ssl.c:1002)')))
報錯:在我設(shè)置好國內(nèi)源之后,用conda創(chuàng)建虛擬環(huán)境,下載python版本時出現(xiàn)以下錯誤
原因分析:從錯誤信息看是無法獲取資源https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/current_repodata.json
, 進(jìn)而通過wget
命令嘗試獲取該資源
解決方法:在命令行中輸入conda config --set ssl_verify false
修改設(shè)置,或者在文件~/.condarc
末尾添加一行ssl_verify: false
(有則修改即可),把清華源那些鏈接里的https改成http。
五、ImportError: cannot import name 'clock' from 'time' (unknown location)
報錯:
原因:這個問題通常出現(xiàn)在Python 3.8版本之后,因?yàn)樵赑ython 3.8中,time模塊中的clock()函數(shù)被廢棄,取而代之的是perf_counter()函數(shù)和process_time()函數(shù)。
解決方法:那么,解決這個問題的方法就是使用perf_counter()函數(shù)或process_time()函數(shù)替代clock()函數(shù)。這兩個函數(shù)分別用于性能計數(shù)和進(jìn)程計時,能夠更準(zhǔn)確地測量時間。
from time import process_time as timer
timer()
?
六、UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x00000200EDD9BEA0>
報錯:
原因:這個鏈接是一張圖片,但是python讀取不到圖片,報錯了,可能是圖片的問題導(dǎo)致讀取不出來。
https://images.mulberry.com/i/mulberrygroup/RL5792_000N651_L/small-hampstead-deep-amber-small-classic-grain-ayers/small-hampstead-deep-amber-small-classic-grain-ayers?v=3&w=304
解決方法:將圖片報錯到本地,將filepath的路徑改為本地路徑文章來源:http://www.zghlxwxcb.cn/news/detail-743674.html
img = Image.open('../images/pack.jpg')
文章來源地址http://www.zghlxwxcb.cn/news/detail-743674.html
到了這里,關(guān)于python 深度學(xué)習(xí) 解決遇到的報錯問題8的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!