gpt4 book ai didi

python - (托管 Django Pythonanywhere)Manage.pycollectstatic 返回 FileNotFoundError : [Errno 2]

转载 作者:太空宇宙 更新时间:2023-11-03 20:47:09 24 4
gpt4 key购买 nike

您好,我在 www.pythonanywhere.com 上部署了一个 python Django 应用程序,该应用程序工作正常,但是当我尝试运行 manage.pycollectstatic 时出现此错误这是我在 settings.py 的代码

STATIC_URL = '/static/'
STATIC_ROOT = '/home/djangopaste/DjangoPaste/djangohost/static'

项目目录到settings.py /home/djangopaste/DjangoPaste/djangohost/管理项目目录.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'```

最佳答案

试试这个:

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

关于python - (托管 Django Pythonanywhere)Manage.pycollectstatic 返回 FileNotFoundError : [Errno 2],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56515715/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com