由于“PermissionError: [Errno 1] Operation not allowed”,我在 macOS 上運行的 Python 腳本無法在 Windows Parallels VM 上打開檔案。但是,如果這些檔案位于 macOS 主機上,該腳本可以使用相同的權限打開這些檔案的副本。
從 macOS 終端,我可以正確打開兩個位置的檔案。
有什么建議嗎?
import os
def main():
fnOnMacOs='/Users/Juhasz/test.txt'
fnOnWinVM='/Volumes/[C] Windows 10 64-bit.hidden/Users/Juhasz/test.txt'
fileOnMacOs=os.open(fnOnMacOs, os.O_RDONLY)
fileOnWinVM=os.open(fnOnWinVM, os.O_RDONLY)
if __name__ == "__main__":
main()
Traceback (most recent call last):
File "/Users/Juhasz/PycharmProjects/accessingVM/main.py", line 10, in <module>
main()
File "/Users/Juhasz/PycharmProjects/accessingVM/main.py", line 7, in main
fileOnWinVM = os.open(fnOnWinVM, os.O_RDONLY)
PermissionError: [Errno 1] Operation not permitted: '/Volumes/[C] Windows 10 64-bit.hidden/Users/Juhasz/test.txt'
open '/Users/Juhasz/test.txt'
open '/Volumes/[C] Windows 10 64-bit.hidden/Users/Juhasz/test.txt'
uj5u.com熱心網友回復:
經過進一步研究,我找到了基于這篇文章的解決方案:PermissionError: [Errno 1] Operation not allowed after macOS Catalina Update
我必須在我的 Mac 上的系統偏好設定中為 PyCharm 設定全盤訪問權限。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/427720.html
