Re: [問題] pyptt遇到的問題已詢問作者但無解

看板Python作者 (謊言接線生)時間2年前 (2021/05/07 16:35), 2年前編輯推噓17(1701)
留言18則, 18人參與, 2年前最新討論串2/2 (看更多)
※ 引述《chin2049 (YesOrNo)》之銘言: : 環境基本上都設定好了 : 作者有確認過 : 但還是Error : 作者也不明白問題出在哪 : 原始碼及執行結果如下 : https://i.imgur.com/udLavmA.png
: 有版友有想法嗎? 好,我也測了一下發現確實有這問題。我幫你(以及原作者)找了一下,我猜問 題出在這裡。websockets的官方文件2.x版本裡面有提到這件事: https://websockets.readthedocs.io/en/2.2/ The websockets.http module provides HTTP parsing functions. They’re merely adequate for the WebSocket handshake messages. They’re used by the sample client and servers. These functions cannot be imported from websockets; they must be imported from websockets.http. 所以websockets.http是一個獨立的module,並沒有被自動import,你需要額外 手動import它。很奇怪的最新版(9.0.1)文件裡面好像沒這段。但不管怎樣,我把 你的Code加一行來測試: import sys import websockets.http from PyPtt import PTT 結果這樣就解決了AttributeError: module 'websockets' has no attribute 'http'這個問題,可以順利執行。 但我不知道為何PyPtt原作者沒有發生這個問題,這可能要他確認一下XD 既然你都問了他,那可以請你順便回報他一下讓他確認看看嗎XD * 2021/05/07 更新問題實際原因與解決狀況 真實的原因是PyPtt使用到的websockets近期做的一個改版(看9.0的部分): https://websockets.readthedocs.io/en/stable/changelog.html The framing, handshake, headers, http, and uri modules in the websockets package are deprecated. These modules provided low-level APIs for reuse by other WebSocket implementations, but that never happened. Keeping these APIs public makes it more difficult to improve websockets for no actual benefit. websockets.http模組被棄用(雖然仍然可以手動import)。而PyPtt作者們信任 websockets,結果沒有特別去鎖相依版本,就導致「只有新安裝PyPtt的使用者,才 會因為跟著裝了9.0以後的websockets導致此問題」。 PyPtt辛苦的作者們正在動手處理此版本相依性問題,幸運的原Po應該可以成為 最初也是最後遇到此問題的幸運兒XD -- 「去質疑親眼所見的事是最愚昧的行為。這又分為兩種--質疑自己所見是不是 真的,或是用見到的事去質疑沒見到的事。呵。」 --芙莉雅,謊言事務所實現使者 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 8.37.43.216 (美國) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1620376501.A.9A3.html

05/07 16:39, 2年前 , 1F
推推
05/07 16:39, 1F
※ 編輯: ddavid (8.37.43.216 美國), 05/07/2021 16:43:20

05/07 16:51, 2年前 , 2F
d大 感謝撥空解答 我跟作者說一聲
05/07 16:51, 2F

05/07 16:54, 2年前 , 3F
太神啦!原來是這樣...我可能是測到比較早的版本
05/07 16:54, 3F
※ 編輯: ddavid (8.37.43.216 美國), 05/07/2021 17:33:29

05/07 18:12, 2年前 , 4F
這就是Free software 的好.
05/07 18:12, 4F

05/07 18:45, 2年前 , 5F
05/07 18:45, 5F

05/07 22:18, 2年前 , 6F
05/07 22:18, 6F

05/07 22:32, 2年前 , 7F
05/07 22:32, 7F

05/08 01:45, 2年前 , 8F
這種親身實驗找原因的精神絕對值得推到爆
05/08 01:45, 8F

05/08 09:17, 2年前 , 9F
05/08 09:17, 9F

05/08 09:31, 2年前 , 10F
05/08 09:31, 10F

05/08 12:25, 2年前 , 11F
用心推
05/08 12:25, 11F

05/08 13:39, 2年前 , 12F
05/08 13:39, 12F

05/08 23:10, 2年前 , 13F
教學相長用心推
05/08 23:10, 13F

05/08 23:24, 2年前 , 14F
05/08 23:24, 14F

05/09 00:44, 2年前 , 15F
這個一定要推一下~
05/09 00:44, 15F

05/09 09:33, 2年前 , 16F
05/09 09:33, 16F

05/09 19:29, 2年前 , 17F
05/09 19:29, 17F

05/10 07:00, 2年前 , 18F
比軟體工作版的文章好多了,這才是RD呀
05/10 07:00, 18F
文章代碼(AID): #1WbFkrcZ (Python)
文章代碼(AID): #1WbFkrcZ (Python)