权限错误:[Errno 1]操作不允许

时间:2019-12-01 04:05:54

标签: python pyinstaller

我正在尝试在pyinstaller中的代码中添加一些.txt文件,但是当我执行pyinstaller maze.spec时,出现权限错误。我以为一个简单的sudo就可以解决这个问题,但是我仍然遇到错误。...关于可能出问题的任何主意吗?

这是我的错误

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/bin/pyinstaller", line 8, in <module>
    sys.exit(run())
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyInstaller/__main__.py", line 112, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyInstaller/__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 732, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 679, in build
    exec(code, spec_namespace)
  File "maze.spec", line 20, in <module>
    exe = EXE(pyz,
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyInstaller/building/api.py", line 443, in __init__
    self.__postinit__()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyInstaller/building/datastruct.py", line 158, in __postinit__
    self.assemble()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyInstaller/building/api.py", line 520, in assemble
    os.remove(self.name)
PermissionError: [Errno 1] Operation not permitted: '/Users/jr194/Bit Club/Test Cases/Maze_Solver_Stack/dist/maze'

此外,我已经检查了迷宫文件夹的权限,并且看来我具有该用户的rwr权限,我敢肯定,这意味着我可以在其中读写。因此,老实说,我对此行为感到困惑。

2 个答案:

答案 0 :(得分:0)

尝试首先获得执行许可,然后执行脚本。为此,请在终端中运行chmod +x maze.spec,然后尝试pyinstaller maze.spec

答案 1 :(得分:0)

您可以尝试(通过命令行,但是我确定python文件中存在一些错误,请先检查Python文件中是否存在任何错误):

您可以尝试:

sudo chown your_username:your_groupname filename

注意:该组通常只是您的用户名。我觉得这些权限有问题。每个人的Read Write Execute似乎已关闭。该文件是如何创建的?没有用户怎么会创建它?