連線Redis報錯的解決方法

2021-09-27 22:30:23 字數 1384 閱讀 1225

使用的python版本:3.7.3

叨叨背景:連線redis,一直報錯!

源**
import redis

client = redis.strictredis()

報錯資訊
traceback (most recent call last):

file "", line 1, in file "c:\program files\jetbrains\pycharm 2018.2.5\helpers\pydev\_pydev_bundle\pydev_umd.py", line 198, in runfile

pydev_imports.execfile(filename, global_vars, local_vars) # execute the script

file "c:\program files\jetbrains\pycharm 2018.2.5\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile

exec(compile(contents+"\n", file, 'exec'), glob, loc)

file "c:/users/zengt/pycharmprojects/untitled/redis.py", line 1, in import redis

file "c:\program files\jetbrains\pycharm 2018.2.5\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import

module = self._system_import(name, *args, **kwargs)

file "c:\users\zengt\pycharmprojects\untitled\redis.py", line 2, in client = redis.strictredis()

attributeerror: module 'redis' has no attribute 'strictredis'

解決方式

終於找到原因!t_t 發現專案目錄下存在檔名與庫名稱相同的檔案 redis.py,所以執行一直報錯!

刪除檔名衝突的檔案後正常執行!!

後記:敲重點!!注意專案檔名不要與系統模組名稱衝突啊!!很可能會報錯 module xx has no attribute ***

Mysql連線時區報錯解決方法

高版本的mysql連線時,可能會報帶有亂報的時區錯誤,解決方法可以參考網上給出的在spring.datasource.url後加一串編碼及時區指定條件試試,不過我的專案加了後仍然不行,所以我採用了修改資料庫伺服器的時間來解決。方法一 臨時,重啟後失效 在mysql的dos視窗或者mysql客戶端輸入...

127報錯解決方法

編譯安裝php 的時候,執行make報錯誤 make ext phar phar.php error 127 解決的方法如下 vi etc ld.so.conf 在裡面加上一行 usr local lib 2.然後執行 sbin ldconfig sbin ldconfig 編譯make make ...

Zimbra mta 報錯解決方法

登陸 提示報錯解決方法 登陸zimbra使用者 su zimbra 報錯服務狀態 zmcontrol status 進入root 模式關閉衝突postfix su root 關閉衝突 postfix service postfix stop 下次重啟關閉 chkconfig postfix off ...