Python 開發常見問題


這里將記錄開發中的常見問題

1.數據庫同步問題VerificationCode.expiration_time:

   WARNINGS:
     api.VerificationCode.expiration_time: (fields.W161) Fixed default value provided.
     HINT: It seems you set a fixed date / time / datetime value as default for this field. This may not be what you want. If you want to have the current date as default, use `django.utils.timezone.now`

  解決:

  

    ·

  

 2. python bs4.FeatureNotFound

  bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

  問題所在:

    bs4.featurenotfound:找不到具有您請求的功能的樹生成器:lxml。

  解決方法:

    pip install lxml

3. selenium.common.exceptions.WebDriverException: Message: 'chromedriver'

  selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

    問題所在:

      這是由於程序找不到 chromedriver 驅動

  解決方法:

   下載 chromedriver     http://chromedriver.storage.googleapis.com/index.html
  注意版本:版本對照表   https://blog.csdn.net/BinGISer/article/details/88559532

4. selenium.common.exceptions.SessionNotCreatedException:

  selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 78

  問題所在:

    這是由於 ChromeDriver 和 Chrome 版本不對應

  解決方法:

    刪除之前下載的 chromedriver

    重新下載 chromedriver  http://chromedriver.storage.googleapis.com/index.html

    注意版本:版本對照表  https://blog.csdn.net/BinGISer/article/details/88559532

5. pip._vendor.urllib3.exceptions.ReadTimeoutError

  pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

  

  問題所在:

    這是由於python 安裝第三方庫,超時報錯--Read timed out.

  解決方法:

    pip install -i https://pypi.doubanio.com/simple pandas

 

    pip  --default-timeout=100000 install scrapy

  

6. RecursionError: maximum recursion depth exceeded while calling a Python object

  RecursionError: maximum recursion depth exceeded while calling a Python object

  

  問題所在:

    遞歸錯誤:調用Python對象時超過了最大遞歸深度

    python默認遞歸深度為1000,超過了就會報錯

  解決方法:

    其實這里的"解決方法" 是不推薦的

這是我原本的代碼:

def func(n): print(n) func(n + 1) func(1)

修改后的代碼:(這里非常不推薦這樣修改

import sys sys.setrecursionlimit(99999999) # 不管數值多大,最多遞歸20963次
def func(n): print(n) func(n + 1) func(1)

7. 'bool' object is not callable

問題描述:
  在django項目中 刪除數據時出現這個問題

問題所在:

  這是由於該條數據和其他表中的數據有關聯

解決方法:

  找到和這條數據有關的所有數據並刪除,最后刪除該條數據

 

8. python pip install face_recognition 失敗

問題描述:

  python 安裝 face_recognition 模塊失敗

  

問題所在:

  這是由於缺少依賴包導致

解決方法:

  pip install cmake

  pip install face_recognition

 

9、ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly

問題描述:

 

  python 安裝 scrapy 失敗

 

 解決方法:

1 python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple/
2 pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple/

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM