Python 在import時明明寫的正確,卻提示錯誤AttributeError: module 'test003' has no attribute 'desc'
在自己寫一個小專案的時候,發現明明自己使用import引入自己專案中的另一個Python檔案是正確的寫法,在執行的時候卻發現總是提示錯誤。因為筆者本人也是學習Python不久,經過一個小時的琢磨,感覺應該是兩個檔案迴圈引用導致錯誤。比如一個a.py在使用的時候需要引用b.py中的方法,然後在b.py使用的時候需要引入a.py中的一個方法。因此自己寫了一個小的案例,經過測試確實是迴圈引用造成衝突所致
在test002.py中寫
在test003.py中寫
然後隨便執行test002或者test003提示
解決辦法:
拆分,將其中某一個test003.py裡兩個功能進行拆分即可
相關推薦
Python 在import時明明寫的正確,卻提示錯誤AttributeError: module 'test003' has no attribute 'desc'
在自己寫一個小專案的時候,發現明明自己使用import引入自己專案中的另一個Python檔案是正確的寫法,在執行的時候卻發現總是提示錯誤。因為筆者本人也是學習Python不久,經過一個小時的琢磨,感覺應該是兩個檔案迴圈引用導致錯誤。比如一個a.py在使用的時候需要引用b.py
import json後,報錯:AttributeError: 'module' object has no attribute 'dumps,原因分析及解決方法
編寫python程式碼,import json後,報錯:AttributeError: 'module' object has no attribute 'dumps',如下圖所示: 報錯資訊為:模組沒有方法dumps 單步除錯: 單步除錯,發現報錯相同。 檢視json
【python學習筆記(2)】指令碼報錯"AttributeError: 'module' object has no attribute 'xxx'"解決方法
最近在編寫Python指令碼過程中遇到一個問題比較奇怪:Python指令碼完全正常沒問題,但執行總報錯"AttributeError: 'module' object has no attribute 'xxx'"。這其實是.pyc檔案存在問題。 問題定位: 檢視imp
python AttributeError module 'string' has no attribute 'upp
Traceback (most recent call last): File "Test1.py", line 8, in <module> upperletters = string.uppercaseAttributeError: module 'st
python AttributeError: 'module' object has no attribute 'setdefaultencoding'
window下使用python,AttributeError: 'module' object has no attribute 'setdefaultencoding'問題的解決方法 參閱了http://www.jb51.net/article/54159.htm後進行整
Python指令碼報錯AttributeError: ‘module’ object has no attribute’xxx’解決方法
最近在編寫Python指令碼過程中遇到一個問題比較奇怪:Python指令碼完全正常沒問題,但執行總報錯"AttributeError: 'module' object has no attribute 'xxx'"。這其實是.pyc檔案存在問題。 問題定位:
[python錯誤]builtins.AttributeError: 'module' object has no attribute 'request'
在python3.4.3版本下,使用wingIDE寫爬蟲的時候, 發生了builtins.AttributeError: 'module' object has no attribute 'request'的錯誤。 錯誤來源是程式碼中的 <span style="fo
Python 3.x中使用urllib出現AttributeError: module 'urllib' has no attribute 'request'錯誤
剛剛開始學習爬蟲,開始寫部落格打算把錯誤記錄下來,已杜自己忘記,並給同樣的小白幫助python 3.x中urllib庫和urilib2庫合併成了urllib庫,python3.X中應該使用urllib.request,即替換掉(python中的)urllib2成urllib.
TensorFlow執行錯誤,AttributeError: module 'pandas' has no attribute 'computation'
TensorFlow執行錯誤,AttributeError: module ‘pandas’ has no attribute ‘computation’ 在我今天剛開始使用TensorFlow做數字識別時,在匯入input_data方法時,即是執行“from
Python錯誤:AttributeError: module 'signal' has no attribute 'SIGALRM'
電腦系統是win10 64位,在使用python的signal模組時報錯:“AttributeError: module 'signal' has no attribute 'SIGALRM'”,這是因為signal模組可以在linux下正常使用,但在windows下卻有一些
安裝CloudStack資料庫時明明密碼輸對了,卻提示錯誤的情況
[[email protected] ~]# cloudstack-setup-databases cloud:[email protected] --deploy-as=root:qwe!123-bash: !123: event not found
明明沒有越界,卻提示index out of range
既然提示了index out of range ,那就是越界了。我估計很多人遇到這個問題都覺得很奇怪,可能都是操作著從檔案裡面讀出來的資料吧。檔案有很多行資料,並不能保證每一行都一定有資料,也不能保證每一行的資料都是那麼多。所以,在對檔案的某一行進行split的時候,可能le
微信公眾平臺支付 一直提示簽名認證失敗,簽名對比正確,卻提示簽名不正確,關於prepay_id造成簽名驗證不正確的問題
關於微信公眾平臺支付的問題,耗時整整24小時,一直在糾結,幾乎是一個字母一個字母的檢視引數是否正確。是的,我已經在開始懷疑人生了。直到在無數篇文章中看見了http://blog.csdn.net/triplestudio/article/details/77930105。開發
20180925:問題:pycharm中匯入flask-wtf失敗,報錯:module 'pip' has no attribute 'main'
前後臺頁面搭建完成,開始後臺邏輯操作。 在開始之前,根據視訊要匯入flask-wtf模組。在pycharm中匯入flask-wtf時,卻顯示報錯,錯誤最後一句提示:module 'pip' has no attribute 'main' 試圖在Termianl面
pytorch低版本載入高版本pytorch訓練得到的模型,出現‘module’ object has no attribute ‘_rebuild_tensor_v2’錯誤
情景 使用pytorch0.3來載入Mobilenetv1的模型(用更高版本的pytorch訓練得到的),出現“AttributeError: ‘module’ object has no attrib
Python基礎學習-'module' object has no attribute 'urlopen'解決方法
參考“http://blog.sina.com.cn/s/blog_5cf74e410102uxsg.html” 用的是python 3.4 非常簡單的一小段程式碼 #!/usr/bin/python # -*- coding: UTF-8 -*- import ur
Python報錯之:AttributeError: 'NoneType' object has no attribute 'seq'
在用matplotlib進行資料視覺化、給圖形新增標籤資料標籤時遇到一個報錯:AttributeError: 'NoneType' object has no attribute 'seq'. 記錄一
scrapy:使用response.follow()方法時出現AttributeError: 'HtmlResponse' object has no attribute 'follow'
執行scrapy出現AttributeError: ‘HtmlResponse’ object has no attribute ‘follow’ 詳細錯誤: 2017-05-20 22:58:44 [scrapy.utils.log] INFO: Sc
python console 丟擲AttributeError: 'PyDevTerminalInteractiveShell' object has no attribute 'has_readli
conda list 查ipython版本版本過高過低都有可能丟擲異常conda uninstall ipythonpip uninstall ipython 解除安裝所有衝突的ipython下載 pip install ipython == 4.2.0
Python學習筆記:AttributeError: 'NoneType' object has no attribute 'text' 解決
#前言 最近在學習python,犯了很多低階錯誤,總結一下 #問題 AttributeError: ‘NoneType’ object has no attribute ‘text’ #出處 difficult = obj.find('d