1. 程式人生 > >global name 'FileNotFoundError' is not defined

global name 'FileNotFoundError' is not defined

昨天在伺服器上執行python的時候發生這個錯誤

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/home/dev/bot-server/BotServer.py", line 17, in run
    bot = Bot(cache_path=True)
  File "/usr/local/lib/python2.7/dist-packages/wxpy/api/bot.py"
, line 88, in __init__ except FileNotFoundError as e: NameError: global name 'FileNotFoundError' is not defined

這個錯誤大致的意思是說找不到檔案(讀寫檔案,或者配置檔案)
於是查看了所需要的檔案和相關的配置都沒有問題,
最後想起來可能是許可權問題 給相關的檔案新增讀寫許可權之後就可以了

還有一種可能是你要寫的資料出現了問題,就是沒有資料可以寫
例如最近弄得微信,要儲存微信登入的資料,但是由於微訊號被封了,所以登入資料為null,所以出現這個錯誤!!!

相關推薦

global name 'FileNotFoundError' is not defined

昨天在伺服器上執行python的時候發生這個錯誤 Exception in thread Thread-1: Traceback (most recent call last): File "

NameError: name 'FileNotFoundError' is not defined的解決方案

處理檔案不存在使用FileNotFoundError來處理異常 python版本:2.7 python程式碼: filename='waiwai.txt' try: with open(fil

NameError: name 'reload' is not defined等python版本問題解決方案

        python2.x和python3.x之間相差很多,有很多語法知識已經不再適用於新的python版本,下面簡單列出3個錯誤: 一、pickle.load錯誤:a bytes-like object is required, not 'str' pickle

Python入門錯誤筆記(1)--object() takes no parameters與name 'label_price' is not defined

學習Python面向物件的時候,寫了一個簡單的關於面向物件的程式: class Product(object): def _init_(self,name): self.name=name self.label_price=0

Python reload(sys) NameError: name 'reload' is not defined

對於 Python 2.X: import sys reload(sys) sys.setdefaultencoding("utf-8") 對於 <= Python 3.3: import im

name ‘reload’ is not defined 解決辦法

                         一段python2.7的程式碼,裡面有如下程式碼: reload(sys) #重新載入sys模組 出現錯誤:name ‘reload’ is not defined 解決辦法: python3.x下應該改為如下方式

paip python NameError name 'xxx' is not defined\

                paip.python NameError name 'xxx' is not defined\匯入一個另一個檔案裡面的函式的時候兒,出孿這個err#這個僅僅匯入孿file...要使用裡面的func,, 要用fullname..     pkg.strUtil.funcName

追夢人物的部落格搭建教程——NameError:name'Category ' is not defined錯誤

在學習追夢人物的部落格搭建教程中,遇到的第一個問題是這個。在敲完資料庫程式碼後,執行python manage.py makemigrations 出現了這種情況(NameError:name'Cat

python name 'file' is not defined的解決辦法

原始碼: poem = '''\ Programming is fun When the work is done if you wanna make your work also fun:         use Python! ''' f = file('poe

python提示NameError: name 'xxx' is not defined

在使用Tkinter時,使用python自己的IDLE執行程式沒問題,當使用命令提示符模式執行會出現錯誤NameError: name 'Tk' is not defined。錯誤出現在from tk

Python2中input出現的name “xxx” is not defined問題原因及解決辦法

# coding=UTF-8 ''' Created on 2017年10月22日 @author: Dyna ''' str_1 = input("Enter a string:") str_2

怎麼解決NameError: name 'driver' is not defined報錯

from selenium import webdriver import timeimport pickle 開頭這裡沒寫錯,為什麼出現這樣的報錯 NameError: name 'driver' is not defined 重新定義一個import driver 也不

NLTK使用中NameError: name 'FreqDist' is not defined問題解決

在使用NLTK學習自然語言處理時,按照《Python自然語言處理》的程式碼進行頻率分佈統計,原始碼如下: <span style="font-size:14px;">fdist1 = Fr

name 'cap_name' is not defined

書上程式碼塊 """ Spyder Editor This is a temporary script file. """ #hello.py def say_hello_to(name): cap_name=name.capitalize() p

Python 遇到NameError: name '_name_' is not defined這樣的錯誤

今天練習寫Python主函式的時候,遇到了NameError: name ‘name’ is not defined 這樣的錯誤。>因為name是一個系統變數,包含了模組的名稱。所以我嘗試著

linux os.listdir() NameError: name 'os' is not defined

從網上摘了一下小測試,向下面這樣 print(os.system('ping xingfushenghuo.com')) 然後報錯了:NameError: name 'os' is not defined 解決方法就是: import os print(os.system

NameError: name 'file' is not defined

poem = '''Program is fun when the work is done if you wanna make your work also fun: use python''' f

python NameError: name 'raw_input' is not defined

錯誤:NameError: name 'raw_input' is not defined 原因出在raw_input ,python3.0版本後用input替換了raw_input 話說回來,學習python,學習教材也要和開發環境同步的,一個版本3一個版本2差距很大

NameError: name xxxxxx is not defined

call spa err n) python編程 發現 冰激淩 nbsp 入門到 python編程,從入門到實踐 9_6 錯題 Traceback (most recent call last): File "9_6.py", line 46, in <modul

NameError: global name 'reduce' is not defined

I'm new to Python. Would you please tell me what's wrong with the following code? When I run it, I got an error message of "NameError: global name 're