在运行PyCharm的情况下运行manage.py collectstatic会在Windows下创建Permission Denied错误

时间:2019-07-14 21:29:52

标签: python django pycharm manage.py collectstatic

在运行PyCharm的Django项目中运行manage.py collectstatic时,出现“权限被拒绝”错误。无论我是从PyCharm还是从命令窗口运行manage.py,这都是事实。当我在运行collectstatic之前关闭PyCharm时,该错误消失了一次,但是现在也无济于事。

我的问题:有没有办法让PyCharm释放对静态文件的保留,以便我可以在不关闭和打开PyCharm的情况下运行collecstatic?

从PyCharm manage.py工具中:

manage.py@liyapilates > collectstatic
"C:\Program Files\JetBrains\PyCharm 2019.1\bin\runnerw64.exe" C:\Users\Opher\PycharmProjects\liyapilates\venv\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm 2019.1\helpers\pycharm\django_manage.py" collectstatic "C:/Users/Opher/Documents/CloudStation/CloudStation/2019 Spring/Django/liyapilates"
Tracking file by folder pattern:  migrations

You have requested to collect static files at the destination
location as specified in your settings:

    C:\Users\Opher\Documents\CloudStation\CloudStation\2019 Spring\Django\liyapilates\staticfiles

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel:  yes
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2019.1\helpers\pycharm\django_manage.py", line 52, in <module>
    run_command()
  File "C:\Program Files\JetBrains\PyCharm 2019.1\helpers\pycharm\django_manage.py", line 46, in run_command
    run_module(manage_file, None, '__main__', True)
  File "C:\Users\Opher\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "C:\Users\Opher\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Users\Opher\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:/Users/Opher/Documents/CloudStation/CloudStation/2019 Spring/Django/liyapilates\manage.py", line 21, in <module>
    main()
  File "C:/Users/Opher/Documents/CloudStation/CloudStation/2019 Spring/Django/liyapilates\manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\core\management\__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\core\management\base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py", line 188, in handle
    collected = self.collect()
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py", line 128, in collect
    for original_path, processed_path, processed in processor:
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\whitenoise\storage.py", line 136, in post_process_with_compression
    for name, hashed_name, processed in files:
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\whitenoise\storage.py", line 87, in post_process
    for name, hashed_name, processed in files:
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\contrib\staticfiles\storage.py", line 403, in post_process
    yield from super().post_process(*args, **kwargs)
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\contrib\staticfiles\storage.py", line 237, in post_process
    for name, hashed_name, processed, _ in self._post_process(paths, adjustable_paths, hashed_files):
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\contrib\staticfiles\storage.py", line 308, in _post_process
    saved_name = self._save(hashed_name, content_file)
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\core\files\storage.py", line 266, in _save
    fd = os.open(full_path, self.OS_OPEN_FLAGS, 0o666)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Opher\\Documents\\CloudStation\\CloudStation\\2019 Spring\\Django\\liyapilates\\staticfiles\\admin\\css\\vendor\\select2\\select2.3805311d5fc1.css'

Process finished with exit code 1

这是在运行PyCharm的命令窗口中进行的(基本上是相同的):

>python manage.py collectstatic

You have requested to collect static files at the destination
location as specified in your settings:

    c:\Users\Opher\Documents\CloudStation\CloudStation\2019 Spring\Django\liyapilates\staticfiles

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\core\management\__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\core\management\base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py", line 188, in handle
    collected = self.collect()
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py", line 128, in collect
    for original_path, processed_path, processed in processor:
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\whitenoise\storage.py", line 136, in post_process_with_compression
    for name, hashed_name, processed in files:
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\whitenoise\storage.py", line 87, in post_process
    for name, hashed_name, processed in files:
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\contrib\staticfiles\storage.py", line 403, in post_process
    yield from super().post_process(*args, **kwargs)
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\contrib\staticfiles\storage.py", line 237, in post_process
    for name, hashed_name, processed, _ in self._post_process(paths, adjustable_paths, hashed_files):
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\contrib\staticfiles\storage.py", line 308, in _post_process
    saved_name = self._save(hashed_name, content_file)
  File "C:\Users\Opher\PycharmProjects\liyapilates\venv\lib\site-packages\django\core\files\storage.py", line 266, in _save
    fd = os.open(full_path, self.OS_OPEN_FLAGS, 0o666)
PermissionError: [Errno 13] Permission denied: 'c:\\Users\\Opher\\Documents\\CloudStation\\CloudStation\\2019 Spring\\Django\\liyapilates\\staticfiles\\admin\\css\\responsive.3a465780d49f.css'

现在,即使我完全关闭PyCharm,我也遇到同样的错误。

0 个答案:

没有答案