[英]Python tempfile.mkstemp(): AttributeError: 'function' object has no attribute 'mkstemp'
不是我的代碼,我正在嘗試一個包含 osascript 庫的工具。
在庫中,在path = temp.tempfile()
行中,會引發標題中的錯誤。
作者正確導入的臨時庫本身具有以下代碼:
f, path = tempfile.mkstemp()
tempfile.mkstemp()
部分就像一個魅力。
因此,由於我們談論的是兩個非常常見且廣泛使用的庫,而且由於我顯然無法在 Google 上找到任何相關的內容,所以我很確定我的本地配置存在一些問題。
我在 macOS 上,使用 python3 (3.7),沒有虛擬環境。
命令pip list --outdated
告訴我這兩個庫實際上已經過時了,但顯然 pip 不會下載更新的版本。 (注意:我的 pip 正確引用了 python3 二進制文件,而不是 macOS 過時的 python 2.7)
osascript 0.0.0 2020.7.2 sdist
temp 0.0.0 2020.7.1 sdist
有任何想法嗎?
重現錯誤的步驟:
>>> import temp
>>> temp.tempfile()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/temp/__init__.py", line 15, in tempfile
f, path = tempfile.mkstemp()
AttributeError: 'function' object has no attribute 'mkstemp'
這是 package temp
中的一個錯誤,它是osascript
的依賴項。 package 導入tempfile
然后立即用 function tempfile
覆蓋它。 報告錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.