(主机Django Pythonanywhere)Manage.py collectstatic返回FileNotFoundError:[错误2]

时间:2019-06-09 15:07:26

标签: python django pythonanywhere

嗨,我在www.pythonanywhere.com上部署了一个python Django应用,该应用运行良好,但是当我尝试运行manage.py collectstatic时,出现此错误 这是我在settings.py

上的代码
STATIC_URL = '/static/'
STATIC_ROOT = '/home/djangopaste/DjangoPaste/djangohost/static'

将项目目录添加到settings.py /home/djangopaste/DjangoPaste/djangohost/ 项目目录为manage.py /home/djangopaste/DjangoPaste/djangohost

跟踪错误

  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/home/djangopaste/.virtualenvs/myenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/home/djangopaste/.virtualenvs/myenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/djangopaste/.virtualenvs/myenv/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/djangopaste/.virtualenvs/myenv/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/home/djangopaste/.virtualenvs/myenv/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 188, in handle
    collected = self.collect()
  File "/home/djangopaste/.virtualenvs/myenv/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 105, in collect
    for path, storage in finder.list(self.ignore_patterns):
  File "/home/djangopaste/.virtualenvs/myenv/lib/python3.6/site-packages/django/contrib/staticfiles/finders.py", line 131, in list
    for path in utils.get_files(storage, ignore_patterns):
  File "/home/djangopaste/.virtualenvs/myenv/lib/python3.6/site-packages/django/contrib/staticfiles/utils.py", line 23, in get_files
    directories, files = storage.listdir(location)
  File "/home/djangopaste/.virtualenvs/myenv/lib/python3.6/site-packages/django/core/files/storage.py", line 315, in listdir
    for entry in os.scandir(path):
FileNotFoundError: [Errno 2] No such file or directory: '/home/djangopaste/DjangoPaste/djangohost/static'```

1 个答案:

答案 0 :(得分:0)

尝试一下:

STATIC_ROOT = os.path.join(BASE_DIR, 'djangohost', 'static')